# TAOCP 4.2.1 Single-Precision Calculations

> Study guide to TAOCP 4.2.1 Single-Precision Calculations. How floating-point numbers are stored (sign, exponent, fraction) and the algorithms for add…

Updated October 20, 2026.

## Summary {#summary}

TAOCP 4.2.1 Single-Precision Calculations: How floating-point numbers are stored (sign, exponent, fraction) and the algorithms for add, subtract, multiply and divide, including normalization and rounding. Budget about 8 hours; do exercises 1, 3 and 4.

Knuth uses his own floating format on MIX, not IEEE 754.

## Key facts {#key-facts}

- Week 75 of 145 on the cracked.guide path, in [TAOCP Vol 2: Seminumerical Algorithms](https://cracked.guide/taocp/volume-2).
- Time budget: about 8 hours.
- 19 exercises in the section, rated 10 to 40; the guide picks 8.
- Picked exercises with Knuth's triangle for recommended: 15.
- Before you start: 4.1 Positional Number Systems and basic MIX.

## Week 75 goals {#objectives}

By the end of week 75 you can:

- Explain how a floating number is stored as sign, exponent and fraction.
- Trace floating addition through alignment, normalization and rounding.
- Compare Knuth's floating format with the IEEE 754 layout.

## This week's steps {#steps}

- Read §4.2.1 Single-Precision Calculations: Read alongside the IEEE 754 Wikipedia page so you can map Knuth's concepts to real hardware.
- Work the exercises (8 picked): Start with Ex 1, Ex 3, Ex 4; log what you solve below.
- Write down one thing you'd explain to someone: A few sentences in your own words in Your notes: the idea, why it works, an example. 30 words ticks this.

## Exercises {#exercises}

This section has 19 exercises, rated 10 to 40, and Knuth marks 1 of them with the triangle for recommended. Only one exercise here is marked recommended, so choose by usefulness: work the small examples by hand, then compare what IEEE 754 does in the same cases.

Worth your time:

- 1 (rated 10): Encode two physical constants in a toy floating-point format.
- 3 (rated 11): The hidden leading bit trick. IEEE 754 uses it.
- 4 (rated 16): Trace floating addition on concrete inputs, including a catastrophic one.
- 10 (rated 12): Find a case where rounding pushes the fraction past 1 during addition.
- 16 (rated HM21): Divide complex numbers without overflow. Smith's algorithm is still used today.
- 15 (rated 28, recommended): Write the fractional-part routine and handle tiny and huge inputs carefully.
- 13 (rated 30): Directed rounding for interval arithmetic.
- 12 (rated M25): Prove that rounding overflow cannot happen when normalizing a quotient. The stretch.

## Why it matters {#why}

Floats are in almost every program and most programmers have only a vague model of them. Implementing float addition yourself is the fastest way to understand why 0.1 + 0.2 is not 0.3.

## Before you start {#before}

- 4.1 Positional Number Systems
- Basic MIX

## How to approach it {#approach}

Read alongside the IEEE 754 Wikipedia page so you can map Knuth's concepts to real hardware. Implement float addition on a toy format (say 8-bit exponent and 16-bit fraction) in C using integers.

## Common traps {#traps}

- Assuming Knuth's format matches IEEE 754. The ideas transfer, the bit layouts do not.

## Links {#links}

- [Knuth's TAOCP page (editions, errata, MIX/MMIX)](https://www-cs-faculty.stanford.edu/~knuth/taocp.html)
- [Vol 2 errata (plain text, from Knuth)](https://www-cs-faculty.stanford.edu/~knuth/err2.textxt)
- [Wikipedia: Floating-point arithmetic](https://en.wikipedia.org/wiki/Floating-point_arithmetic)
- [Wikipedia: IEEE 754](https://en.wikipedia.org/wiki/IEEE_754)
- [Hacker News: What Every Computer Scientist Should Know About Floating-Point Arithmetic](https://news.ycombinator.com/item?id=23665529)

---

Source: https://cracked.guide/guide/knuth-w058-0
cracked.guide: A free, dated 145-week path to getting genuinely cracked at programming.
