Binary Calculator: How Binary Works & How to Convert Numbers
Quick Answer
Binary is a base-2 number system using only 0 and 1. Every decimal number converts to binary by expressing it as a sum of powers of 2. To convert 1010 to decimal: (1×8) + (0×4) + (1×2) + (0×1) = 10. All modern computers run on binary because transistors have exactly two stable states.
- *Binary-to-decimal: multiply each bit by its power of 2, then sum.
- *Decimal-to-binary: divide by 2 repeatedly, read remainders bottom-up.
- *One byte = 8 bits = 256 possible values (0–255).
- *Hexadecimal is shorthand for binary: every 4 bits = 1 hex digit.
What Is the Binary Number System?
Binary is a positional number system with a base of 2. Where decimal (base-10) uses ten digits (0–9), binary uses only two: 0 and 1. Each digit in a binary number is called a bit (short for binary digit).
The position of each bit determines its value. Just as the decimal number 345 means (3×100) + (4×10) + (5×1), the binary number 1101means (1×8) + (1×4) + (0×2) + (1×1) = 13.
According to IEEE standards, virtually every processor manufactured since 1970 operates on binary logic. The entire internet — every image, video, and message — is ultimately stored and transmitted as sequences of 0s and 1s.
Why Computers Use Binary
The choice of binary isn't arbitrary. Transistors, the fundamental building blocks of modern chips, have two stable electrical states: high voltage and low voltage. These map naturally to 1 and 0.
Moore's Law — the observation that transistor counts roughly double every two years — has held for over 50 years. As of 2025, Apple's M4 chip packs approximately 28 billion transistors into a chip smaller than a thumbnail. Every one of those transistors is switching between binary states billions of times per second.
Binary also has a practical noise-resistance advantage. In a two-state system, a signal is either clearly “high” or clearly “low.” Electrical interference has to push a signal almost halfway across the range to cause an error. Multi-state systems (base-3, base-10) would require far more precise voltage control, making them unreliable at the microscale.
Binary to Decimal Conversion: Positional Notation
Converting binary to decimal uses the positional value of each bit. Assign powers of 2 to each position, starting from 0 at the rightmost bit and increasing left.
| Bit Position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Power of 2 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Example: Convert 10110101 to decimal
(1×128) + (0×64) + (1×32) + (1×16) + (0×8) + (1×4) + (0×2) + (1×1)
= 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1
= 181
Skip the steps by using our Binary Calculator— it handles any bit length instantly.
Decimal to Binary Conversion: The Divide-by-2 Algorithm
To convert a decimal number to binary, repeatedly divide by 2 and record the remainder at each step. When you reach 0, read the remainders from bottom to top.
Example: Convert 45 to binary
| Division | Quotient | Remainder |
|---|---|---|
| 45 ÷ 2 | 22 | 1 |
| 22 ÷ 2 | 11 | 0 |
| 11 ÷ 2 | 5 | 1 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Reading remainders from bottom to top: 101101. Verify: (1×32) + (0×16) + (1×8) + (1×4) + (0×2) + (1×1) = 32 + 8 + 4 + 1 = 45. Correct.
Binary Addition Rules
Binary addition follows four simple rules. The tricky one is 1+1, which equals 10in binary — zero written down, one carried to the next column.
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Example: Add 1011 + 0110
Working right to left:
1+0=1 → write 1, carry 0
1+1=10 → write 0, carry 1
0+1+1(carry)=10 → write 0, carry 1
1+0+1(carry)=10 → write 0, carry 1
Carry produces a new leading 1
Result: 10001 = 17 in decimal (11 + 6 = 17). Correct.
For subtraction, multiplication, and division, see our Binary Calculator which shows full step-by-step working.
Hexadecimal: Binary's Shorthand
Long binary strings are hard to read. Hexadecimal (base-16) solves this by grouping every 4 bits into a single hex digit. Hex uses digits 0–9 plus letters A–F (A=10, B=11, C=12, D=13, E=14, F=15).
| Decimal | Binary | Hex |
|---|---|---|
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
The 32-bit color value #FF5733 breaks into three byte pairs: FF (255 red), 57 (87 green), 33 (51 blue). In binary that's 11111111 01010111 00110011 — 24 bits that would be unwieldy to write out every time. Hex makes it human-readable. See our hex color codes guide for a full breakdown.
Conversion Reference Table: Decimal 0–20
| Decimal | Binary | Hex | Octal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 3 | 11 | 3 | 3 |
| 4 | 100 | 4 | 4 |
| 5 | 101 | 5 | 5 |
| 6 | 110 | 6 | 6 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 8 | 10 |
| 9 | 1001 | 9 | 11 |
| 10 | 1010 | A | 12 |
| 11 | 1011 | B | 13 |
| 12 | 1100 | C | 14 |
| 13 | 1101 | D | 15 |
| 14 | 1110 | E | 16 |
| 15 | 1111 | F | 17 |
| 16 | 10000 | 10 | 20 |
| 17 | 10001 | 11 | 21 |
| 18 | 10010 | 12 | 22 |
| 19 | 10011 | 13 | 23 |
| 20 | 10100 | 14 | 24 |
Octal (base-8) groups binary in sets of 3 bits and was common in older Unix systems. Today it survives mainly in Unix file permissions — see the section below.
5 Real-World Applications of Binary
1. Computer Memory and Storage
Every byte in RAM is 8 bits. A 16 GB RAM stick holds 137 billion bits. Hard drives and SSDs store data as magnetic or electrical states that map directly to binary. According to IDC, the world generates approximately 120 zettabytes of data annually — every bit of it stored in binary. Our data storage converter guide shows how bits scale up to terabytes and beyond.
2. Networking and IP Addresses
IPv4 addresses are 32 bits written in four decimal octets (e.g., 192.168.1.1). Subnet masks, routing tables, and network operations all work in binary. IPv6 uses 128 bits, enabling 3.4 × 10³&sup8; unique addresses — more than enough for every atom on Earth to have its own IP address.
3. Logic Gates and Processors
AND, OR, NOT, NAND, NOR, and XOR gates are the physical implementation of binary logic. Every arithmetic operation your CPU performs — addition, subtraction, comparison — reduces to combinations of these gates. A modern CPU executes billions of these binary gate operations per second.
4. Color Codes in Web Design
The CSS color #8B5CF6 (the purple used on this page) is three bytes: red=8B (139), green=5C (92), blue=F6 (246). In binary: 10001011 01011100 11110110. The 24-bit RGB color model supports exactly 16,777,216 unique colors (2²&sup4;). See our hex to RGB guide for conversion details.
5. Unix File Permissions
Unix permissions use octal (base-8), which maps to 3-bit binary groups. The permission chmod 755 means 111 101 101in binary — owner has read+write+execute (7=111), group has read+execute (5=101), others have read+execute (5=101). Every Linux and macOS file permission is fundamentally a binary flag set.
Bits, Bytes, and Data Sizes
Understanding binary means understanding how data scales:
| Unit | Bits | Bytes | Common Use |
|---|---|---|---|
| Bit | 1 | 0.125 | Single binary digit |
| Nibble | 4 | 0.5 | One hex digit |
| Byte | 8 | 1 | One ASCII character |
| Kilobyte (KB) | 8,192 | 1,024 | Short text document |
| Megabyte (MB) | 8,388,608 | 1,048,576 | One minute of MP3 audio |
| Gigabyte (GB) | ~8.6 billion | 1,073,741,824 | ~250 smartphone photos |
An 8-bit byte can represent 256 values (2&sup8;). A 16-bit integer covers 65,536 values (2¹&sup6;). A 32-bit float covers over 4 billion values. The exponential scaling of bits is why adding just one bit doubles capacity — the same principle behind statistical distributions growing rapidly with added dimensions.
Binary in Programming
Most programming languages let you write binary literals directly. In Python, 0b1010 is the integer 10. In JavaScript, 0b11111111 is 255. Bitwise operators — AND (&), OR (|), XOR (^), NOT (~), left shift (<<), right shift (>>) — manipulate numbers at the binary level and are critical in systems programming, cryptography, and graphics.
A left shift by 1 bit (x << 1) multiplies by 2. A right shift by 1 bit (x >> 1) divides by 2 (integer division). These bit-shift operations are faster than arithmetic multiplication on many processors.
Convert binary, decimal, hex, and octal instantly
Try our free Binary Calculator →Also useful: Scientific Calculator • Standard Deviation Calculator
Related Math Guides
Binary is the foundation of computing, but mastering other number tools sharpens your quantitative thinking:
- How to Calculate Standard Deviation — the backbone of statistics and data analysis
- Percentage Calculator Guide — percentages in everyday math and business
- How to Use a Scientific Calculator — scientific notation, exponents, and logarithms
- Quadratic Formula Guide — solving second-degree equations step by step
Frequently Asked Questions
How do you convert binary to decimal?
To convert binary to decimal, multiply each bit by its positional power of 2 and sum the results. For 1010: (1×8) + (0×4) + (1×2) + (0×1) = 10. Start from the rightmost bit (position 0) and work left, doubling the positional value with each step.
How do you convert decimal to binary?
Use the divide-by-2 algorithm: repeatedly divide the decimal number by 2 and record the remainder. Read the remainders from bottom to top. For 13: 13÷2=6 R1, 6÷2=3 R0, 3÷2=1 R1, 1÷2=0 R1. Reading upward gives 1101, which is 13 in binary.
Why do computers use binary?
Computers use binary because transistors have two stable states: on and off, which map perfectly to 1 and 0. Binary logic is noise-resistant — a signal is either high voltage or low voltage, with no ambiguity. This makes binary circuits far more reliable than multi-state alternatives at scale.
What is a byte in binary?
A byte is 8 binary bits grouped together. It can represent 256 unique values (2&sup8;), ranging from 00000000 (0) to 11111111 (255). A byte is the standard unit for storing a single character of text. A kilobyte is 1,024 bytes; a megabyte is 1,024 kilobytes.
What is the relationship between binary and hexadecimal?
Hexadecimal (base-16) is a shorthand for binary. Every 4 binary bits map to a single hex digit (0–9, A–F). For example, the binary byte 11001010 splits into 1100 (C) and 1010 (A), giving the hex value CA. Programmers use hex because it compresses long binary strings into readable short codes.
How does binary addition work?
Binary addition follows four rules: 0+0=0, 0+1=1, 1+0=1, and 1+1=10 (zero with a carry of 1). Adding 1011 and 0110 gives 10001 (11+6=17 in decimal). Carry propagation works exactly like decimal addition but with only two digits instead of ten.