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.0 * 2^-128biased exponent = -128+127 = -1 = 1111 11111.0 * 2^1biased 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?
Floating Point representation -128+127 = -1 = 1111 1111
computer architecture
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.