# Why does IEEE 754 Single Float have 8 bits for exponent but only allow 38 base ten Max Value

Why is it that the IEEE 754 standard provide 8 bits for the exponent but puts a range maximum of 38 on the largest acceptable exponent?

Seems kind of ridiculous to have the data storage there but not allow it to actually be used.

I wanted to pack data into this exponent for some encoding I'm doing, but I can't use all the bits because I can't pack an exponent larger than 38! I was hoping to pack values up to 256 using all bits (2 ^ 8).

Floating point stores the exponent and mantissa in base two, not base 10. Two to the 127th power corresponds roughly to ten to the 38th power, so that's the largest decimal number that can be stored.

• I started to realize this was where I went wrong after the other poster responded, but you really helped clear it up succinctly. Thanks for realizing my error. :) Dec 24, 2013 at 6:05

IEEE 754 standard single-precision (i.e., 32-bit) floats reserve 1 bit for the sign bit, 8 for the exponent, and 23 for the mantissa. I'm not sure where you're getting a value of 38 (base 10) from as the "maximum" exponent. Please clarify in the comments if I'm interpreting this incorrectly.

Since the exponent is 8 bits, the range of exponent values can be anywhere between 00000000 and 11111111 (which are reserved for 0 and infinity, respectively). However, any exponent value between 00000001 and 11111110 is valid. So, accounting for a bias of -127, you can achieve an exponent of 127.

So, assuming a mantissa of all 1's (i.e., a value very close to 2), you can achieve up to 2^127 for your encoding.

If all you need is 2^8 for your encoding, consider using overall fewer bits in your floating point number.