-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
12
ADDITIONAL SYSTEM INFORMATION :
Windows, jdk 8, 7 and any since the beginning I think.
A DESCRIPTION OF THE PROBLEM :
The java doc for Float.intBitsToFloat
"(...) floating-point value according to the IEEE 754 floating-point "single format" bit layout.(...)"
then
"(...)Then the floating-point result equals the value of the mathematical expression s·m·2e-150(...)"
while IEE 754 says: "exponent bias: -127".
Double includes similary inconsitentinformation.
I could test it on Windows but I can't test it on other operating systems. Thous I can't give a formal warranty to my customers if code based on this method will work correctly on their OS.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Either read IEEE or run belo code snippet.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Result should be "JDK is correct".
Honestly, in my opinion it should alternate randomly from call to call. Just kidding. No method can work according to docs if docs are contradicting itself.
ACTUAL -
Observed: "JDK is wrong".
---------- BEGIN SOURCE ----------
int v = (127+8)<<23;
float f = Float.intBitsToFloat(v);
System.out.println("f="+f);
if (f==(1<<8))
System.out.println("JDK is wrong");
else
System.out.println("JDK is correct");
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
IEEE specs are correct. Math equations in JDK are incorrect.
This bug is a duplicate of Bug ID:JDK-4702593 Error in Float.intBitsToFloat documentation which was resolved as "not a bug". Really, guys? Can't You just correct four letters? Since 2002?
FREQUENCY : always
Windows, jdk 8, 7 and any since the beginning I think.
A DESCRIPTION OF THE PROBLEM :
The java doc for Float.intBitsToFloat
"(...) floating-point value according to the IEEE 754 floating-point "single format" bit layout.(...)"
then
"(...)Then the floating-point result equals the value of the mathematical expression s·m·2e-150(...)"
while IEE 754 says: "exponent bias: -127".
Double includes similary inconsitentinformation.
I could test it on Windows but I can't test it on other operating systems. Thous I can't give a formal warranty to my customers if code based on this method will work correctly on their OS.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Either read IEEE or run belo code snippet.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Result should be "JDK is correct".
Honestly, in my opinion it should alternate randomly from call to call. Just kidding. No method can work according to docs if docs are contradicting itself.
ACTUAL -
Observed: "JDK is wrong".
---------- BEGIN SOURCE ----------
int v = (127+8)<<23;
float f = Float.intBitsToFloat(v);
System.out.println("f="+f);
if (f==(1<<8))
System.out.println("JDK is wrong");
else
System.out.println("JDK is correct");
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
IEEE specs are correct. Math equations in JDK are incorrect.
This bug is a duplicate of Bug ID:
FREQUENCY : always
- duplicates
-
JDK-4702593 Error in Float.intBitsToFloat documentation
-
- Closed
-
- relates to
-
JDK-4702593 Error in Float.intBitsToFloat documentation
-
- Closed
-