knowledge
knowledge

Reputation: 1015

IEEE-754 32 Bit (single precision) exponent -126 instead of -127

I know if I have a number like that:

1 | 1001 0001 | 0011 0011 0000 0001 0101   000 
1 sign bit | 8 bit biased exponent | 23 bit fraction/mantissa

I can calculate the "real" exponent by subtraction the bias 127 (0111 1111) from biased exponent. I.e. 1001 0001 - 0111 1111 = 10010 (so real Exponent is 18)

1,0011 0011 0000 0001 0101 000 * 2^18

So now my question:

If a have a (denormalized) number like that:

0 | 0000 0000 | 0000 0000 0000 0000 0000   001 

Why the Exponent is -126 and not -127? 0000 0000 - 0111 1111 should be -127 and not -126 so that

0,0000 0000 0000 0000 0000 0001 * 2^-126 and not 0,0000 0000 0000 0000 0000 0001 * 2^-127

Thanks and best regards

Upvotes: 3

Views: 1017

Answers (1)

dbush
dbush

Reputation: 223689

A denormalized single precision float has an implicit exponent of 2-126:

(−1)signbit×2−126× 0.significandbits

See https://en.wikipedia.org/wiki/Single-precision_floating-point_format for more details.

Upvotes: 3

Related Questions