# Thread: Storage and interpretation of double precision numbers

1. ## Storage and interpretation of double precision numbers

I have a few questions about doubles:

The way I understand it, a double is a sign bit, followed by an 11 bit integer exponent, and 53 bit mantissa. The exponent is stored as an unsigned int, and is biased by -1023 when it is interpreted as a double.

So, to my understanding, in memory a double looks like:

sign bit - 11 bit UNSIGNED integer - 53 bit mantissa

Is it true that the exponent is always unsigned until it is interpreted? Or is there even any real difference between the stored bits and the interpreted value besides the fact that the unsigned int is read as a signed one?

This question is not very clear I don't think.... Hm.

If I compare the bits of two exponents directly in memory, and one of them is -1 after the bias is applied and the other is 1, will -1 appear to be larger than 1, for example?

or am I misunderstanding something fundamental here (more likely :P)

2. I think you missed the whole "1023" part. The exponent is not stored. The exponent, plus 1023, is stored (as an unsigned number, yes, because quite frankly the stored number by definition can never be negative). So an exponent of -1 is stored as the (actual) number 1022 and +1 is stored as the (actual) number 1024.

3. Right, so a comparison between the two will yield -1 < 1. I was told elsewhere that a comparison of the bits would give a result showing that 1 < -1. Thanks for clearing that up.

4. Originally Posted by KBriggs
I was told elsewhere that a comparison of the bits would give a result showing that 1 < -1.
Well it will if the one with the larger exponent happens to be holding a negative number (sign bit is set)...

5. I am only interested in comparing the 11 exponent bits, the sign bit can be easily handled separately.

6. That's referred to as biasing the exponent. You can read more about it here.