Why should you care about terminating binaries? Because, IDK, computers? Computers use binary? Or something like that.
But that’s beside the point. (No pun intended.)
Now let’s say I’m a computer. In computer science class a while back, I learned that there is a “floating point” representation that uses binary to represent decimals. Some decimals can be represented accurately in binary, which is nice. But some can’t.
How does the “float” type work? Let’s take a look at the IEEE 754-2008 documentation for a floating point number (available at www.math.fsu.edu/~gallivan/courses/…/IEEE-fpstandard-2008.pdf.gz):
So how does a 32-bit number work? Here are some definitions:
- Segment “S” is known as the “sign.” It’s exactly what you think it is. One for negative, zero for positive.
- Segment “E” is known as the “exponent.” This is an 8-bit unsigned expression for 32-bit numbers, and represents the power of two to multiply the following number by. (For the super-nerdy: a bias of 127, or 01111111, is added to the exponent so that negative exponents can be expressed as well).
- Segment “T” is known as the “mantissa.” The mantissa is normalized – that is, in truncated scientific notation. Example: Take the binary number 10.001101. This is expressed as
. Then, this is truncated to 0001101 to form the mantissa.
So here’s an example: how do you express the number in binary, floating-point style?
- Find out how to express 12.375 in base 2. It’s relatively easy in this case: 8 + 4 + 0.25 + 0.125, or
- Convert this to base-2 scientific notation:
- Truncate that.
- Now you have all your information! Sign 0, exponent 11, and mantissa 100011.
Play around with http://www.easysurf.cc/fracton2.htm in your free time. If you notice repeating decimals, you know where to look: Part 4!
<< Part 2: How Binaries Work
Part 4: Yum, Repeating Binaries >>







