Data Representation and Operation

A computer stores nothing but bit patterns. Every integer, every character, every floating-point value it manipulates is a fixed-length string of zeros and ones, and every arithmetic result it produces is a rule for rewriting one such string into another. This chapter closes that gap: it shows how a quantity you recognise as a number becomes a pattern of bits, and how the hardware then operates on that pattern without ever knowing what it represents.

Two threads run through the material. The first concerns representation — positional number systems and the conversions between them, the sign-magnitude, one’s complement, and two’s complement encodings of a signed integer, the ranges and the special cases each one implies, and the character encodings that let a machine hold text. The second concerns operation: how adders and subtractors are built from gates, how a multiplier and a divider work, and how the arithmetic logic unit ties them together behind a control signal.

The chapter is deliberately concrete. Every representation is carried out on paper-sized examples — eight bits wide, small enough to write in a margin — because the point is not to memorise a table of encodings but to see what each one buys and what each one costs. Two’s complement is the one worth internalising, because its single-operation arithmetic is what lets the hardware implement subtraction as addition and lets signed overflow be detected with a single rule.

Floating-point arithmetic is treated separately, both because its representation differs and because its behaviour surprises people. The IEEE 754 layout, the alignment and normalisation steps an addition performs, and the rounding decisions that quietly trade exactness for range are all developed here, along with the accumulated error that follows from them.

By the end you should be able to take a decimal number, produce its machine form by hand, perform an addition or a multiplication on it, and say precisely when the result is wrong and why. That fluency is what the instruction set and the CPU chapters will build on, because every instruction in a real machine is an operation of exactly this kind.

Chapters

Found an issue with this content?

Tell us what could be improved.