I give you credit for printing FLT_MAX
out in %a
format, so you can see what the value actually is, as opposed to what %f
prints it as. So why not do that for the value of mant
, too?
frexp(0x1.fffffep+127) = {0x1.fffffep-1, 128}
That result seems unsurprising to me. (Note that the exponent in the IEEE-754 representation is based on a mantissa in the range [1.0, 2.0)
, whereas frexp
generates a mantissa in the range [0.5, 1.0)
. So the frexp
maximum exponent is one higher.)
Moral: Never confuse what a floating point value is with how it looks.