...
| Code Block | ||
|---|---|---|
| ||
class Test{
public static void main(String[] args){
int big = 1999999999;
double big_float = big;
float one = 1.0f;
System.out.println(big*one); // binary operation, loses precision due to implicit cast
double big_float = big;
System.out.println(big_float); // double is a wider type, preserves precision
}
}
|
...
| Code Block | ||
|---|---|---|
| ||
class Test{
public static void main(String[] args){
int big = 1999999999;
double big_float = big;
double one = 1.0d; // double instead of float
System.out.println(big*one);
double big_float = big;
System.out.println(big_float);
}
}
|
...