Place value with two choices
Binary is a positional number system with two digits: zero and one. Moving one place left doubles that position’s value. This is the same idea as decimal notation, where moving left multiplies the position value by ten. The physical computer does not need to contain tiny written numbers. The digits describe distinguishable states used to represent information. Harvard’s binary introduction provides the foundational place-value explanation.
For an unsigned integer, add the position values wherever a one appears. The interpretation must be agreed before decoding the bits. A pattern is not inherently a positive integer, a letter, or a machine instruction.
Decode an original example
Take the eight-bit pattern 00101101. Its positions, from left to right, have values 128, 64, 32, 16, 8, 4, 2, and 1. The ones occur at 32, 8, 4, and 1. Their sum is 45. Leading zeroes do not change that unsigned value, just as 0045 and 45 denote the same decimal number.
To go in the other direction, start with 45. The largest power of two that fits is 32, leaving 13. Then take 8, leaving 5; take 4, leaving 1; and finally take 1. Mark these positions with ones and the other positions with zeroes. This method makes the conversion checkable without relying on a converter.
Count patterns before choosing a field
Three bits provide eight patterns: the unsigned values zero through seven. Four bits provide sixteen patterns. In general, n binary positions provide two to the power n distinct patterns. Because zero uses one pattern, an n-bit unsigned integer’s largest value is one less than that count.
Suppose a message must represent twelve status codes. Three bits are insufficient, because only eight distinct choices fit. Four bits are enough, with four patterns left unused. Those unused patterns might be reserved, treated as errors, or assigned meaning later. The protocol must say which. Making the field bigger can simplify future additions, but it also changes the space required across many records.
Signed values need a convention
A negative number is not obtained simply by attaching a human minus sign to a stored byte. The representation defines how bit patterns map to signed values. Two’s complement is a common fixed-width convention, but the width and interpretation matter. Mixing a signed interpretation with an unsigned one can turn the same payload into very different numbers.
Programming languages can also separate mathematical values from fixed-width storage. Python accepts a 0b prefix for binary integer literals; its lexical reference defines that syntax. The literal describes an integer value. It does not, on its own, require an eight-bit field in a network packet or file.
Representation is an engineering decision
Return to the twelve-status message. A receiver needs to know the field width, the bit ordering within the format, the meaning of each code, and what to do with unrecognized values. Without that agreement, transmitting perfectly preserved bits does not guarantee shared meaning.
When debugging a data format, inspect both the raw pattern and the declared type. Check boundary values such as zero, the highest valid value, and the first value that does not fit. Avoid assuming that more printed zeroes mean more information. A clear representation contract makes it possible to reason about storage, overflow, and interoperability. The next step is understanding bits and bytes as size units, then mathematical representations for values that need more than unsigned whole numbers.