# Floating Point representation -128+127 = -1 = 1111 1111

While reading Computer Architecture by Patterson (page 194) I got this question. IEEE 754 uses 127 as bias for single precision floating point so that it will be easy to compare floating point numbers using hardware.

1. 1.0 * 2^-128
biased exponent = -128+127 = -1 = 1111 1111

2. 1.0 * 2^1
biased exponent = 1+127 = 128 = 1000 0000

For hardware compare 1) comes out to be a larger number than 2) which is wrong. Can anybody explain how comparing is working for these two numbers?

The exponent is unsigned. It cannot be `-1`. The smallest it can be is `0`, which translates to `2^-127`.

You might ask then, "If so, how is `2^-128` represented in single precision?!".

The answer lies in `normalization`.

Usually numbers are `normalized` (i.e. multiplied by a power of 2) so that the leading bit of their mantissa is `1`. That bit can then be omitted, giving you extra precision (or removes redundancy, depending on who you ask).

It was decided for ~reasons~ (to enable a gradual loss of precision during underflow), that it's not worthwhile keeping to this schema when the exponent is `-127`. Rather the leading bit is whatever the leading bit is.

What this does, is it decreases resolution in the range `2^-127 to 2^-126` but allows to represent additional numbers below `2^-127`.

Hence, `2^-128` will have an exponent of `0` (translated to `-127` via the bias), and a mantissa of `010000...000`. Note that, unlike all normalized numbers, the mantissa means `0.5` - which is outside the usual range of the mantissa for normalized numbers (`1.0 to 2.0`).

With this in mind - the exponent comparison makes easy sense - `128` is larger than `0` :)

All this is also given in the wiki article on IEEE 754-1985 (and probably others) in the very first section.

• That does help.And In The book its written that pattern of all one 1111 1111 is reserved for (+-) infinity. and I think we even can't denote 1 * 2^-128 with only 32 bits in hand. Upto 1 * 2^-126 we can denote it without any problem . – prashant singh Jul 27 '15 at 3:13
• @prashantsingh Indeed, an exponent of `1111 1111` is reserved - for infinity if the mantissa is `0`, or `NaN` in case it's non-zero. If floating point numbers were always normalized then indeed, `2^-128` would not be possible to represent in this format. I found this site useful when answering this question. – Ordous Jul 27 '15 at 11:59