I know we can\'t compare 2 floating point values using ==. We can only compare they are within some interval of each other. I know
if(val == 0.512) >
if(val == 0.512)
Use the tolerance / ephsilon approach.
I just evaluated the following in Java, which mathematically results in zero:
1.0/5.0 + 1.0/5.0 - 1.0/10.0 - 1.0/10.0 - 1.0/10.0 - 1.0/10.0
and actually got
2.7755575615628914E-17