Grades 6–8 · Computing
How do zeros and ones represent whole numbers in binary?
A numeral represents a number using digits and place weights. Decimal uses ten possible digits and weights that multiply by ten when moving left. Binary is base two: it uses only zero and one, and each place weighs twice as much as the place immediately to its right.
In the diagramBinary places have powers-of-two weightsUnsigned integer: 131608142Weights: 16, 8, 4, 2, 18 + 4 + 1 = 13A zero keeps a place but contributes no value.
The five places shown here have weights sixteen, eight, four, two and one. A one selects a weight. A zero contributes no value but keeps the other digits aligned with their places. That placeholder role matters: moving a digit to another place can change its contribution.
The initial integer thirteen is written 01101 in these five places. The selected weights are eight, four and one. Their sum is thirteen. The leading zero contributes no sixteens, so removing that leading zero would not change the number. Removing an interior zero, however, would shift other place positions.
This representation is unsigned, meaning that all values are zero or positive. Five binary places can represent integers from zero through thirty-one. Other conventions are needed for negative numbers or fractional quantities. The digits describe the same integer that a decimal numeral describes; the place-value system, rather than the quantity, has changed.
About this explanation
Starting knowledge: Understand ordinary decimal place value and add powers-of-two weights up to sixteen.
Sources
- University of Canterbury, Computer Science Field Guide — Data Representation: Numbers