FULL PRODUCT VERSION :
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
float x = 2.1f * 2.55f;
Expected result x = 5.355, precise number, clearly far away from any limit (min/max of float)
Actual result x = 5.3549995 (?)
if compared:
2.1f * 2.55f > 5.3549995 => result: true (correct)
2.1f * 2.55f > 5.3549996 => result: false (incorrect. 2.1*2.55=5.355 > 5.3549996)
The same problem is also with double;
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
float x = 2.1f * 2.55f;
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected result x = 5.355, precise number, clearly far away from any limit (min/max of float)
ACTUAL -
Actual result x = 5.3549995 (?)
if compared:
2.1f * 2.55f > 5.3549995 => result: true (correct)
2.1f * 2.55f > 5.3549996 => result: false (incorrect. 2.1*2.55=5.355 > 5.3549996)
REPRODUCIBILITY :
This bug can be reproduced always.
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
float x = 2.1f * 2.55f;
Expected result x = 5.355, precise number, clearly far away from any limit (min/max of float)
Actual result x = 5.3549995 (?)
if compared:
2.1f * 2.55f > 5.3549995 => result: true (correct)
2.1f * 2.55f > 5.3549996 => result: false (incorrect. 2.1*2.55=5.355 > 5.3549996)
The same problem is also with double;
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
float x = 2.1f * 2.55f;
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected result x = 5.355, precise number, clearly far away from any limit (min/max of float)
ACTUAL -
Actual result x = 5.3549995 (?)
if compared:
2.1f * 2.55f > 5.3549995 => result: true (correct)
2.1f * 2.55f > 5.3549996 => result: false (incorrect. 2.1*2.55=5.355 > 5.3549996)
REPRODUCIBILITY :
This bug can be reproduced always.