1.3 Floating Point Representation¶
This note explains how one might go about expressing floats in binary or hexadecimal systems using IEEE representation of floating point numbers. Get back to toc CS61C or 1. Number Representation
Floats¶
Now we are tasked with finding some sort of representation for numbers that lie between two other binary numbers. We want to accomplish two main goals with our representation:
- Represent huge numbers as well as little numbers
- Represent signed numbers
Rather than doing something like writing the dot between the binary number to have whole numbers and part numbers, such as \(0b011.1 = 3 + 0.5 = 3.5\). We want to take advantage of the scientific notation for binary numbers as well as the binary that appears after the binary point (is it called binary point... you know, like decimal point. I'll call it the binary point). To do this, we split any floating point number into three distinct parts:
- Sign: We will encode a 0 to be positive, and 1 to be negative
- Exponent: Will encode the scientific notation power for binary numbers
- Mantissa: The numbers after the binary point in scientific notation
The number of bits we dedicate to each part depends on the precision, but the sign bit will always be 1 bit.
``