Binary

A base-2 numeral system using only 0 and 1, which serves as the foundational language for all digital computing.

The modern binary system was formalized by Gottfried Wilhelm Leibniz in the 17th century, though binary logic systems existed in ancient cultures (like the I Ching).

Unlike the base-10 decimal system we use daily (where each position represents a power of 10: 1s, 10s, 100s), binary positions represent powers of 2 (from right to left: 1, 2, 4, 8, 16, 32...).

For example, the binary number 1011 is calculated as:
(1 × 8) + (0 × 4) + (1 × 2) + (1 × 1) = 11 in decimal.

Eight bits are grouped together to form a byte, which can represent 256 unique values (0 to 255).

        graph LR
  Center["Binary"]:::main
  Rel_bit["bit"]:::related -.-> Center
  click Rel_bit "/terms/bit"
  Rel_byte["byte"]:::related -.-> Center
  click Rel_byte "/terms/byte"
  Rel_hexadecimal["hexadecimal"]:::related -.-> Center
  click Rel_hexadecimal "/terms/hexadecimal"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 Knowledge Check

1 / 5

🧒 Explain Like I'm 5

Computers don't understand letters, words, or pictures. They are just giant calculators made of billions of tiny light switches. A switch can only be ON (1) or OFF (0). Binary is simply a long list of 'on/off' signals that the computer uses to do everything, from showing this text to playing a video game.

🤓 Expert Deep Dive

Binary Arithmetic and Logic
At the ALU (Arithmetic Logic Unit) level, binary math is performed using logic gates (AND, OR, XOR) derived from Boolean algebra.

Data Representation
- Integers: Unsigned integers simply use the base-2 positional values. Signed (negative) integers are universally represented using Two's Complement (invert all bits and add 1), which elegantly allows the same adder circuits to handle both addition and subtraction.
- Floating-Point: Decimal fractions are approximated using the IEEE 754 standard, which divides a 32-bit or 64-bit string into a sign bit, an exponent, and a mantissa.

Endianness
When storing multi-byte binary values in memory, architectures must decide order: Big-Endian stores the most significant byte at the lowest memory address, while Little-Endian (used by x86 processors) stores the least significant byte first.

❓ Frequently Asked Questions

Why do computers use binary instead of decimal?

It's a physical limitation. It is much easier, cheaper, and reliable to build electrical switches that have only two clear states (ON/OFF or High/Low Voltage) rather than trying to accurately measure ten different voltage levels for a base-10 system.

What is the difference between a bit and a byte?

A 'bit' is a single binary digit (a single 0 or 1). A 'byte' is a group of 8 bits strung together. One byte is enough data to represent a single letter, like 'A' (which is 01000001 in binary).

How do you count in binary?

In decimal, you count 0 to 9 and then roll over to 10. In binary, you only have 0 and 1, so you roll over immediately. The counting goes: 0, 1, 10, 11, 100, 101, 110, 111 (which translates to 0, 1, 2, 3, 4, 5, 6, 7 in decimal).

📚 Sources