I am rewriting an old Java 6 Program written to perform some scientific calculations in Java 8 and stuck up in this situation where I'm getting different results for rounding operation.
Java 6 is rounding an input like 0.499999999999999999994
to 1
but Java 8 is making it 0
. I'm not able to understand the problem here.
For Instance:
private void foo() {
System.out.println(Math.round(0.499999999999999999994));
}
The above code behaves differently for different Java versions.
It would be great if someone could shed some light on this issue.