Reputation: 23
I'm trying to understand an excerpt about IEEE 754 format as read in Jason Gregory's book Game Engine Architecture. The troublesome part says as follows:
You can find the chapter this excerpt belongs to on this free sample.
Given than binary multiplication, 0x00FFFFFF x 2^127, I expected 127 binary zeros would be added to the right of the first operand, but instead only 104 binary zeros (127 - 23) are added. Why are these 23 zeros being removed?
Upvotes: 1
Views: 97
Reputation: 224092
The book is wrong. The 24 bits of the significand (1 encoded by whether the exponent field is zero or non-zero and 23 stored explicitly in the significand field) are properly interpreted as a leading bit followed by a radix point followed by 23 bits. So if the 24 bits are 0xffffff, the mathematical significand is 0x1.fffffe, and the value represented when the exponent field is 254 (which encodes an exponent value of 127) is 0x1.fffffe β’ 2127.
The following text is also wrong about the minimum floating-point value. The binary representation it presents, 0x00800000, is for the smallest normal value. There are smaller values, called subnormal values. The representation of the smallest non-zero value representable in the IEEE-754 32-bit binary floating-point value is 0x00000001, and the value it represents is 2β149.
The text after that has an incorrect definition of the machine epsilon, asserting it is the smallest floating-point value π that satisfies 1+π β 1. A proper definition of the machine epsilon is that it is the difference between 1 and the smallest representable value greater than 1. These definitions differ because, if π is the correct machine epsilon, a value of x slightly over Β½π will satisfy 1+x β 1 because rounding will occur during computation of 1+x, causing it to be rounded upward to 1+π instead of downward to 1.
That paragraph also misstates how addition of a value smaller than π operates, stating a smaller value will be βchopped off.β Most commonly, floating-point operations round to the nearest representable value, although IEEE-754 does define other rounding methods.
Upvotes: 2