TAOCP Vol 2: Seminumerical Algorithms · Week 74
TAOCP 4.1 Positional Number Systems
Updated
Summary
TAOCP 4.1 Positional Number Systems: Number representations: binary, octal, hex, and exotic systems like negative bases, balanced ternary, and mixed radix. Budget about 5 hours; do exercises 1, 9 and 2.
Knuth also covers a little history of how positional notation developed.
This week's steps
3 stepsRead §4.1 Positional Number Systems
Convert a few numbers to base -2 and balanced ternary by hand.
Start with Ex 1, Ex 9, Ex 2; 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.
Sign in to track this: tick each step off and it counts toward your week.
Exercises
This section has 34 exercises, rated 00 to M40, and Knuth marks 8 of them with the triangle for recommended. Do the conversion drills quickly and then implement negabinary addition and the minimal signed-digit form; those are the exercises that pay back in code.
Worth your time
Exercise 224▶ Recommended
Express a few numbers in four unusual systems. Shows the tradeoffs side by side.
Exercise 13M21▶ Recommended
Whether expansions in base -10 can be ambiguous, like 0.999... in decimal.
Exercise 3422▶ Recommended
Write an integer with digits -1, 0, 1 using the fewest nonzero digits. Used in fast exponentiation and hardware multipliers.
Your log
Sign in to log the exercises you work: number, rating, how far you got.
Your notes
Only youSign in to keep private notes on this guide, in Markdown. They stay yours: never on your profile, and you can export them all.
Discussion
0 postsQuestions about the reading go here; each exercise has its own thread below. Hints over answers.
No posts yet. Ask a question or share a tip.
Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise threads
One thread per exercise. Open one to ask for a nudge or check your thinking.
Exercise 115No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 224No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 915No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 1122No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 13M21No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 1923No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 31M35No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 3422No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Reference
Why it matters
Bit manipulation, encodings and serialization formats all depend on fluent radix thinking. Mixed radix is how you convert time units and index multi-dimensional arrays.
Before you start
- 1.2.4 Integer Functions
How to approach it
Convert a few numbers to base -2 and balanced ternary by hand. Write a function that converts to any mixed radix.
Common traps
- Rushing through the negative-base examples. They are fun and they check your understanding.