⚙️ DevOps Utilities
How Binary Works: Binary Numbers Explained
By Justin Le
· 6 min read · Updated June 27, 2026 Everything a computer does comes down to 1s and 0s. Binary looks alien at first, but it works exactly like the decimal system you already know — just with two digits instead of ten. Once that clicks, bits, bytes and hexadecimal all make sense.
Why computers use binary
Computers are built from billions of tiny switches that are either on or off. Two states map perfectly to two digits: 1 (on) and 0 (off). Representing data in base 2 is simply the most natural fit for the hardware, and it's robust — a circuit only has to tell "high" from "low," not ten different voltage levels.
Place values: base 2 vs base 10
In decimal (base 10), each position is a power of ten: ones, tens, hundreds. In binary (base
2), each position is a power of two: ones, twos, fours, eights, and so on. That's the only
difference. Reading right to left, the binary number 1011 is:
- 1 × 8 = 8
- 0 × 4 = 0
- 1 × 2 = 2
- 1 × 1 = 1
Add them up: 8 + 0 + 2 + 1 = 11 in decimal.
Converting decimal to binary
To go the other way, repeatedly subtract the largest power of two that fits. For 13: the
largest power of two ≤ 13 is 8, leaving 5; then 4, leaving 1; then 1. So you have 8 + 4 + 1,
which is positions 8, 4, and 1 set: 1101. (There's also a divide-by-2 method, but
the powers-of-two approach is more intuitive.)
Bits and bytes
A single binary digit is a bit. Eight bits make a byte, which can represent 2⁸ = 256 different values (0–255). That number is everywhere: a color channel, a character in older text encodings, one octet of an IPv4 address. Larger values just use more bytes.
Why hexadecimal rides along
Long binary strings are hard for humans to read, so programmers use
hexadecimal as shorthand. Because 16 = 2⁴, one hex
digit equals exactly four bits, and two hex digits equal one byte. So 11111111
becomes FF — much easier to handle. Binary, hex and decimal are just three views of
the same value.
A note on negative numbers
Computers represent negative integers using a scheme called two's complement, where the highest bit indicates the sign and negation is done by flipping the bits and adding one. You don't need it for everyday conversions, but it's why an 8-bit signed number ranges from −128 to 127 rather than 0 to 255.
Try it
Convert between binary, octal, decimal and hex instantly with our number base converter, and turn text into its raw bytes with the hex ↔ text converter. For the hex side of the story, read hexadecimal explained.
Frequently asked questions
How do you convert binary to decimal?
Each binary position is a power of two (1, 2, 4, 8, …). Multiply each digit by its position value and add them up. For example 1011 = 8 + 0 + 2 + 1 = 11 in decimal.
Why do computers use binary?
Computers are built from switches that are either on or off — two states that map naturally to the two binary digits, 1 and 0. Base 2 is the most reliable fit for the hardware.
How many values can a byte represent?
A byte is 8 bits, so it can represent 2^8 = 256 different values, from 0 to 255. That's why a single IPv4 octet or color channel ranges 0–255.
Try the related tools
- Number Base Converter Convert between binary, octal, decimal and hexadecimal — with big-number support.
- Hex ↔ Text Converter Convert text to hexadecimal and decode hex back to text, with UTF-8 support.
- Subnet Calculator (IPv4 CIDR) Enter an IP and CIDR to instantly get the netmask, network, broadcast, host range and total number of addresses.
Related guides
- Hexadecimal Explained: Why Programmers Use Hex Why 0xFF beats 11111111: how hexadecimal works, its clean mapping to bytes, and where you'll meet it — colors, addresses, hashes and more.
- What Is an IP Address? What an IP address is and how it routes your traffic — public vs private, static vs dynamic, and why your phone and your router don't share the same one.
- Unix Timestamps Explained: Epoch, Seconds vs Milliseconds Epoch time, demystified: what the number really means, the seconds-vs-milliseconds bug that bites everyone, and why timestamps have no timezone.