hex / binary to floating point representation
Posted on 2003-03-18
hi, i saw a post by surball that asked how to convert a hex value into a floating point representation.
the example given was: 0x3f800000 should yield 1.0
one of the suggested answers (by heyhey) was as follows:
long binData = 0x3f800000;
double d = Double.longBitsToDouble(binData);
however, when i print out the value for "d", i get 5.263544247E-315.
question 1: why is this answer different from the expected "1.0"?
question 2: i assume the binary representation of 0x3f800000 is: 0011 1111 1000 0000 0000 0000 0000 0000. is there a simple java method to convert that binary representation into its corresponding floating point value?
THANK YOU IN ADVANCE FOR ANY HELP YOU CAN PROVIDE!