DCFPT - Don't Compare Floating Point Types
Avoid testing floating point numbers for equality: floating-point numbers that should be equal are not exactly equal due to rounding problems.
Wrong
if ( d != 15.0 ) {
for ( double f = 0.0; f < d; f += 1.0 ) {
// do something
}
}
}
Tip: Replace direct comparison with estimation of absolute value of difference
Right
if ( Math.abs(d - 15.0) < Double.MIN_VALUE * 2 ) {
for ( double f = 0.0; d - f > DIFF; f += 1.0 ) {
// do something
}
}
}