Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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).

share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

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.

See https://www.google.com/#q=2+to+the+127th+power

share|improve this answer
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. :) –  Jim Dec 24 '13 at 6:05
add comment

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.

Read more here: http://steve.hollasch.net/cgindex/coding/ieeefloat.html

share|improve this answer
Ah, now I see his confusion. If he wants 256 as the exponent in the corresponding decimal number, then he needs to use a double-precision floating point number, which can yield a maximum exponent of 308 (base 10). Though I'm not sure this is what he's trying to ask... –  bunting Dec 24 '13 at 5:48
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.