floating point - Interpreting the bit pattern of FLT_MAX -


flt_max has bit pattern of 01111111011111111111111111111111.

if understand correctly, such bit pattern should represent 1.111...1 * 2^128 (with twenty-three 1's after decimal). however, actual value of flt_max 1.0 * 2^128. what's going on here?

your exponent wrong, it's 1.111...1 * 2^127 = 2^128 - 2^104. pretty close (relatively) 2^128, , need print out more default precision in c or c++ see difference (note, float - if ieee754 32-bit float - 2^128 infinity, need double).

the bit pattern yields

  0   11111110  11111111111111111111111   ^      ^             ^ sign  exponent     mantissa        254-127     2 - 2^(-23) 

printing full values:

340282346638528859811704183484516925440.0   // flt_max 340282366920938463463374607431768211456.0   // 2^128 

you can see difference @ eighth digit.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -