How Do Binary Numbers Actually Work — From the Ground Up?
Binary numbers are just numbers written in base 2, which means each digit is either 0 or 1 and each position has a power-of-two value. If you want to sanity-check a bit pattern while you read, try our free binary to decimal tool and let the machine do the adding for you.
The trick is simple once it clicks: binary uses place value exactly like decimal, but with 1, 2, 4, 8, 16, and so on instead of 1, 10, 100, 1000. That makes it the native language of bits, bytes, masks, flags, and low-level hardware, even when you only touch it through code.
Binary is place value with a smaller alphabet
Decimal works because every position means a power of 10. The number 507 means 5 hundreds, 0 tens, and 7 ones. Binary uses the same structure, but each column is a power of 2.
So the binary number 1011 means:
1 × 80 × 41 × 21 × 1
Add those up and you get 11 in decimal. Nothing mystical is happening. Binary numbers are just a different counting system with fewer digits and stricter rules.
The rightmost bit is the least significant bit, or LSB. Move one place left and the value doubles. That pattern keeps going forever, or until you run out of bits.
Why computers like bits so much
Hardware is easiest to build around two stable states: on and off, high and low, charged and uncharged. Binary maps cleanly onto that reality. A transistor does not need to pretend it understands ten different symbols when it can just treat one voltage as 1 and another as 0.
That is why memory, storage, network packets, and CPU instructions are all ultimately bit patterns. A byte is just eight binary digits bundled together, which gives you 256 possible combinations from 00000000 to 11111111.
If you have ever seen a permission mask like rw-r--r--, a feature flag, or a protocol field packed into one integer, you have already touched binary thinking. The code may look decimal on the surface, but the hardware underneath is doing bitwise work.
For a deeper related dive, see our guide on bitwise operations.
How to read binary without counting on your fingers
The fastest way to read binary is to scan from right to left and mark every position that contains a 1. Each marked position contributes its power of two to the final total. Ignore the zeros; they are just empty slots.
Here is the mental model:
- Write the powers of two under the bits.
- Pick every column with a
1. - Add those values together.
Example: 110101 becomes 32 + 16 + 4 + 1. That equals 53. Once you can do that in your head, binary stops looking like a code and starts looking like a sum.
This also explains why extra leading zeros do not change the value. 000101 and 101 mean the same number. They only differ in width, which matters for formatting, not mathematics.
Bits, bytes, and the ranges they create
One bit has two states. Two bits have four states. Three bits have eight states. The pattern is exponential because every new bit doubles the number of possible combinations.
That is why an 8-bit byte has 256 possible values. You can represent numbers from 0 to 255 if the byte is unsigned. If the system uses signed two’s complement, the same 8 bits usually represent -128 to 127.
That signed range surprises people because the leftmost bit often acts like a sign indicator in human explanations, but in two’s complement it is more like a weighted place value with a negative twist. The exact details matter when you are debugging overflows, serializing data, or reading raw memory.
In practice, bytes are the unit most developers end up caring about. File sizes, network payloads, encodings, and image data all move around in byte-sized chunks, even if the interface pretends otherwise.
Binary in code: masks, flags, and shortcuts
Binary becomes useful when you start treating each bit as a switch. That is what bit masks do: they let you turn features on and off inside one number. This is common in systems code, permissions, and performance-sensitive paths where a compact representation matters.
In JavaScript, for example, you can test a flag with & and set it with |:
const READ = 1; // 0001
const WRITE = 2; // 0010
const EXEC = 4; // 0100
let perms = READ | WRITE; // 0011
const canWrite = (perms & WRITE) !== 0;
const canExec = (perms & EXEC) !== 0;That pattern scales because one integer can store several yes/no values without needing an array or object. It is compact, fast, and slightly unreadable if nobody documents the bits. Which is very on-brand for old codebases.
Binary also shows up in networking. IPv4 addresses, for example, are just 32 bits grouped into four octets. If you want to see how that looks under the hood, our post on how IPv4 addresses are represented in binary is the natural next stop.
Decimal to binary and back, the manual way
Converting decimal to binary is the reverse of reading it. Repeatedly divide by 2 and keep the remainders. Read the remainders from bottom to top, and you have your binary number.
Example: 11 in decimal becomes 1011 in binary.
- 11 ÷ 2 = 5 remainder 1
- 5 ÷ 2 = 2 remainder 1
- 2 ÷ 2 = 1 remainder 0
- 1 ÷ 2 = 0 remainder 1
Read the remainders upward: 1011. The same idea works for larger numbers, though the list gets longer and your patience gets shorter.
Back the other way, multiply each bit by its power of two and add the results. That is the whole game. A calculator or converter is just a faster version of the same process.
A Worked Example
Let’s convert one number both ways so the pattern stops feeling abstract. Start with binary 110101. Assign powers of two from right to left:
Binary: 1 1 0 1 0 1
Value: 32 16 8 4 2 1Now pick the columns with 1:
32 + 16 + 4 + 1 = 53So 110101 equals 53 in decimal. If you wanted to verify that quickly in your browser, paste the bits into the binary to decimal converter and compare the result.
Now go the other direction. Take 53 and divide by 2:
53 ÷ 2 = 26 remainder 1
26 ÷ 2 = 13 remainder 0
13 ÷ 2 = 6 remainder 1
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1Read the remainders upward: 110101. Same value, different representation, same underlying machine logic.
Frequently Asked Questions
Why do computers use binary instead of decimal?
Because digital hardware naturally distinguishes between two stable states more reliably than ten. Binary maps cleanly to those states and makes circuits simpler to build and debug. Decimal is easier for humans, but binary is easier for electronics.
How do I convert binary numbers to decimal by hand?
Start from the rightmost bit and assign powers of two: 1, 2, 4, 8, 16, and so on. Add the values where the bit is 1 and skip the zeros. That sum is the decimal value.
What is the difference between a bit and a byte?
A bit is a single binary digit, either 0 or 1. A byte is usually 8 bits grouped together. Bytes are the common unit for storage and file sizes, while bits are often used for flags, masks, and low-level data layout.
How do negative binary numbers work?
Most modern systems use two’s complement. In that scheme, the same bit pattern can represent positive or negative values depending on its most significant bit and the arithmetic rules around it. It is efficient for CPUs, but it is worth learning separately because it does not behave like signed decimal notation.
The Bottom Line
Binary numbers are not a special trick so much as a smaller counting system with rigid place value. Once you understand that each position is a power of two, reading and converting binary becomes mechanical instead of mysterious.
If you are checking a bit pattern, debugging a mask, or just trying to keep the place values straight, use the math by hand once or twice, then let the browser do the tedious part. You can always use this binary to decimal tool to confirm the result before you move on to the real problem.
That is usually the cleanest workflow: understand the bits, verify the sum, and keep your attention on the code that actually matters.