What is Binary? — The Base-2 Number System Explained
Definition
Binary is a base-2 numeral system that uses only two digits: 0 and 1, called bits. Every piece of data a computer processes — numbers, text, images, programs — is ultimately stored and manipulated as sequences of these bits. A group of 8 bits is called a byte, which can represent 256 distinct values (2^8). Binary maps directly to the two electrical states (off/on, low/high voltage) that digital circuits can represent.
How It Works
Each bit position in a binary number represents a power of 2. The rightmost bit is 2^0 (1), the next is 2^1 (2), then 2^2 (4), 2^3 (8), and so on. To convert binary to decimal, add together the powers of 2 wherever there is a 1. For example, 1011 binary = 2^3 + 2^1 + 2^0 = 8 + 2 + 1 = 11. Text is encoded in binary by mapping each character to its ASCII or Unicode code point and storing that number in binary. An image is stored as binary values for each pixel's color channels.
Common Use Cases
- ▸Understanding how integers and floats are stored in memory
- ▸Working with bitmask flags and bitwise operators in code
- ▸Reading binary file formats and network protocol specifications
- ▸Debugging low-level issues with CPU registers and memory dumps
- ▸Learning how data compression and encoding algorithms work at the bit level
Example
Decimal 42 = Binary 101010 Decimal 255 = Binary 11111111 (one byte, all bits set) Decimal 0 = Binary 00000000 ASCII "A" = decimal 65 = binary 01000001 ASCII "a" = decimal 97 = binary 01100001
Related Tools
Convert binary numbers to decimal, hexadecimal, and octal.
Convert decimal numbers to binary, hexadecimal, and octal.
Convert space-separated binary bytes to readable text.
Convert text to space-separated 8-bit binary bytes.
Perform arithmetic on binary numbers. See results in binary, decimal, and hex.
FAQ
- What is the difference between a bit and a byte?
- A bit is the smallest unit of data, holding either 0 or 1. A byte is 8 bits. A kilobyte is 1,024 bytes (or 1,000 bytes in SI units). Network speeds are often measured in bits per second (Mbps), while storage sizes use bytes (MB, GB).
- How does binary represent negative numbers?
- Negative integers are typically stored using two's complement. To negate a binary number, invert all bits and add 1. In an 8-bit system, -1 is stored as 11111111. This scheme makes binary addition and subtraction work correctly for both positive and negative numbers.
- What is a bitwise operation?
- Bitwise operations (AND, OR, XOR, NOT, left shift, right shift) manipulate individual bits. They are used to set, clear, and test flag bits in integers, perform fast integer multiplication and division by powers of 2, and implement low-level graphics and cryptography operations.