The Algebra Of Two’s Complements

Explaining the mathematics behind the standard way of representing negative numbers in binary.
→ [preprint] ←  Keywords: #binary-representation #twos-complements #modular-arithmetic

How computers represent negative numbers is usually taught at time when students are not familiar with modular arithmetic, which means it has to be taught as gospel: the students learn what the rules are, but not why they are as they are. Moreover, those students that go on pursuing paths that lead them to learn modular arithmetic, have by that time bigger things on their plate to be worrying about binary representations… So this is one thing that students usually graduate without understanding. Additionally, I could could not find any decent explanation of the mathematics of two’s complements. And so I wrote one myself.

Status of the preprint: finished except (optional) section 2, that aims to provide some of the needed results of modular arithmetic. Otherwise it is complete—which means readers already familiar with that branch of mathematics will be able to read it without loss.

May 14, 2024. Got feedback? Great, email is your friend!

*   *   *

Update history

May 26, 2024. Corrected typos and improved the explanation of when (and when not) does modular addition coincide with regular integer addition. The version prior to this update can be retrieved here.