1Learning Outcomes¶
Practice converting between IEEE 754 single-precision floating point formats to decimal numbers.
🎥 Lecture Video
In this course, we will expect that you should be able to translate between a number’s IEEE 754 Floating Point format and their decimal representation. We give some examples below.
In practice, you can and should use floating point converters. This web app gives a fantastic converter that you can and should use to explore numbers beyond those discussed below!
2Example 1: Floating Point to Decimal¶
Show Answer
E. -7.5.
We separate these 32 bits into the bit fields of sign (1 bit), exponent (8 bits), and significand (23 bits) first and translate each part separately.
s: 1, so sign is negative
exponent:
1000 0001is , so exponent value issignificand:
1110....0is111, so mantissa value is1.111(in base 2)
Plug into our formula, noting that components are decimal unless otherwise noted with subscript:
Second to last line: involves moving the binary point to the left by two spots, e.g., .
Last line: Integer component
111is 7; fractional component.1is .
For those interested, this means that writing the C statement float x = -7.5; results in x having the bit pattern 0xC0F00000.
3Example 2: Step size with limited precision¶
Because we have a fixed # of bits (precision), we cannot represent all numbers in a range. With floating point numbers, the exponent field informs our step size.
Show Answer
We consider the next representable number after y. This involves incrementing the significand by 1 in the least significant bit, which corresponds to the smallest possible increment (“step size”):
| s | exponent | significand |
|---|---|---|
0 | 1000 0001 | 111 0000 0000 0000 0000 0001 |
This new number is y + z, for some small step size z:
Instead of translating y and this new number y + z, then taking their difference, we instead note that we are trying to find z itself. Let’s figure out exactly what power of 2 z represents, given the provided exponent.
The least significant bit .0....01, for any mantissa of a binary normalized form:
Implicit leading 1 is not represent by any of 23 bits but corresponds to 20
bit 22 (most significant bit) of significand is 2-1
bit 0 (least significant bit) of significand is 2-23
In other words, for an exponent value of (with no shifts), z would be 2-23. However, with our exponent field, we shift over this bit to the appropriate power.
The exponent value for 10000001 is . This shifts over 2-23 right by two. Our step size z is therefore
Bigger exponents mean bigger step sizes, and vice versa. This is actually the desired behavior: when we have super large numbers, fractional differences become infinitesimal. However, with tiny numbers, smaller step sizes are more valuable and our precision (as represented by the bits of the significand) must go towards representing differences.
4Example 3: Floating Point to Decimal¶
5Example 4: Decimal to Floating Point¶
Show Answer
6Example 5: Decimal to Floating Point¶
This exercise shows the limitations of accurate representation using the fixed-precision IEEE 754 standard. After all, fixed precision means we only have 32 bits, and binary representations sometimes fall short.


