Glossary

What Is Binary? Base-2 Number System Explained

Binary is the base-2 number system, using only two digits: 0 and 1. It is the native language of digital computers because transistors — the building blocks of processors — are switches that are either off (0) or on (1). Every piece of data in a computer — from text to images to programs — is stored and processed as sequences of binary digits (bits).

Bits and Bytes

A bit (binary digit) is the smallest unit of data: a single 0 or 1. A byte is 8 bits — enough to represent 256 values (2^8). Common units: kilobyte (KB) = 1,024 bytes; megabyte (MB) = 1,048,576 bytes; gigabyte (GB) = 1,073,741,824 bytes. Note: storage manufacturers often use SI prefixes (1 KB = 1,000 bytes) while operating systems use binary units (1 KiB = 1,024 bytes).

Binary to Decimal Conversion

Each bit position represents a power of 2, starting from 2^0 = 1 on the right. Example: 1011 in binary = (1×2^3) + (0×2^2) + (1×2^1) + (1×2^0) = 8 + 0 + 2 + 1 = 11 in decimal. To convert decimal to binary: repeatedly divide by 2 and record remainders read from bottom to top.

Two's Complement

Computers represent negative integers using two's complement: invert all bits and add 1. For 8-bit signed integers: 0–127 are positive, 128–255 represent -128 to -1. This encoding makes binary addition work identically for positive and negative numbers, eliminating the need for separate subtraction hardware.

Binary vs Hex in Practice

Binary is verbose — the byte 0xFF requires 8 binary digits (11111111). Since 4 bits map exactly to one hex digit, hexadecimal is the preferred compact notation for binary data in programming. Developers rarely write raw binary; hex (0x...) notation is used for memory addresses, byte values, bit masks, and color codes.