Floating point numbers should not be tested for equality. Issue #46

This commit is contained in:
Ilja Dubinin 2015-08-17 01:14:34 +01:00 committed by Roman Ivanov
parent 8a276f35fd
commit f17f1410a5
1 changed files with 2 additions and 1 deletions

View File

@ -173,7 +173,8 @@ public class ExplicitInitializationCheck extends Check {
case TokenTypes.NUM_INT:
case TokenTypes.NUM_LONG:
final String text = expr.getText();
return CheckUtils.parseDouble(text, type) == 0.0;
return Double.compare(
CheckUtils.parseDouble(text, type), 0.0) == 0;
default:
return false;
}