If the argument is 0x7ff0000000000000L, the
result is positive infinity.
If the argument is 0xfff0000000000000L, the
result is negative infinity.
If the argument is any value in the range
0x7ff0000000000001L through 0x7fffffffffffffffL or
in the range 0xfff0000000000001L through
0xffffffffffffffffL, the result is a NaN. No IEEE
754 floating-point operation provided by Java can
distinguish between two NaN values of the same
type with different bit patterns. Distinct values
of NaN are only distinguishable by use of the
In all other cases, let s, e, and m be three
values that can be computed from the argument:
int s = ((bits >> 63) == 0) ? 1 :
int e = (int)((bits >> 52) & 0x7ffL);
long m = (e == 0) ?
(bits & 0xfffffffffffffL)
<< 1 :
(bits & 0xfffffffffffffL) |
Then the floating-point result equals the
value of the mathematical expression
The conversion can be done in reverse. For
"normal" numbers x, let
s be the sign
of the value,
e be floor(log2(x)) +
m be rounded from
x/2e, and shift the values
s is the high bit,
e is the next 11 bits,
is the remaining 52 bits.