I have the following statement:
float diff = tempVal - m_constraint.getMinVal();
tempVal
is declared as a float and the
Floats use the IEEE754
to represent numbers, and that system has some rounding errors.
Floating point guide
What Every Computer Scientist Should Know About Floating-Point Arithmetic
Wikipedia on IEE754
Bottom-line if you are doing arithmetic and it needs to be exact don't use float
or double
but us BigDecimal