...
In this noncompliant code example, a value of type int
is converted to the type float
. Because type float
has only 23 mantissa bits, the result of subtracting the original from this value is non -46, not zero.
Code Block | ||
---|---|---|
| ||
class WideSample { public static void main(String[] args) { int big = 1234567890; float approx = big; // This is expected to be zero but it prints -46 System.out.println(big - (int)approx); } } |
...