Computing Library › Number Systems & Information
Number Systems & Information

Binary Number System

Binary represents every number with just two digits, 0 and 1, matching the two states of a switch.

Base two

Binary is positional notation in base 2. Each digit, called a bit, has weight equal to a power of two. The string 1011 means 1×8 + 0×4 + 1×2 + 1×1 = 11 in decimal.

Why computers use it

Kronos motion — number counters

A physical switch, a voltage level, or a magnetic domain has two stable states. Mapping these to 0 and 1 makes storage and logic robust: a value only has to be distinguished as high or low, not measured precisely.

Counting in binary

Counting proceeds by carrying just like decimal, but a carry happens after 1 instead of after 9: 0, 1, 10, 11, 100, 101. Each new bit position doubles the range of representable values.

Bits, bytes, and words

Eight bits form a byte, which represents 256 distinct values. Wider groupings called words (16, 32, or 64 bits) hold larger integers and addresses. n bits represent 2ⁿ distinct patterns.

Reading long strings

Because binary strings grow quickly, they are often grouped in fours or eights and written in hexadecimal for legibility. This is presentation only; the stored value is identical.

python
n = 0b1011
print(n)            # 11
print(bin(11))      # '0b1011'
print(11 .bit_length())  # 4