Number System Converter
Computers use binary internally; humans use decimal; hexadecimal is a compact shorthand for binary. Type a value in any base and see it converted instantly.
Base Converter
● liveBinary Adder & Subtractor
All arithmetic inside a computer is carried out in binary, using only the digits 0 and 1. Try the rules yourself below.
Binary Adder
Enter two binary numbers (0s and 1s only).
Binary Subtractor
Subtracts B from A directly (borrow method). A must be ≥ B.
| A | B | Sum | Carry | A | B | Difference | Borrow | |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | |
| 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | |
| 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 |
Number Systems
In a positional number system, a digit's value depends on its face value and its place value (a power of the base).
Decimal · Base 10
Digits 0–9. Not used inside computers, but essential for showing results to humans.
Binary · Base 2
Digits 0–1. Matches the ON/OFF (high/low) states of transistors in a computer's ICs.
Hexadecimal · Base 16
Digits 0–9, A–F. Each hex digit = a 4-bit binary group — a compact shorthand for binary.
(11010)2 = 1×2⁴ + 1×2³ + 0×2² + 1×2¹ + 0×2⁰ = 16 + 8 + 0 + 2 + 0 = 26
(10A)16 = 1×16² + 0×16¹ + A×16⁰ = 256 + 0 + 10 = 266
The digit with the highest place value is the Most Significant Digit/Bit (MSD/MSB); the one with the lowest is the Least Significant Digit/Bit (LSD/LSB).
Representation of Integers
Using an 8-bit word length, computers represent signed integers with three common methods.
Sign & Magnitude
MSB = sign (0 positive, 1 negative); remaining 7 bits = magnitude.
= −109
1's Complement
Positive numbers stay as-is; for negatives, invert every bit of the positive form.
= −92
2's Complement
1's complement + 1. Used by modern computers — no separate "negative zero".
= −75
Why 2's Complement Wins
| Decimal | Sign & Magnitude | 1's Complement | 2's Complement |
|---|---|---|---|
| +0 | 000 | 000 | 000 |
| −0 | 100 | 111 | — |
| −1 | 101 | 110 | 111 |
| −4 | — | — | 100 |
Sign & Magnitude and 1's Complement both have a wasted "negative zero" representation. 2's Complement eliminates it, and lets computers use the same hardware to add and subtract — by adding the complement of the subtrahend.
Floating Point Numbers
A real number is stored as N = (−1)sign × (1.mantissa) × 2exponent — like scientific notation, but base 2. The IEEE 754 standard defines Single precision (32-bit: 1 sign + 8 exponent + 23 mantissa) and Double precision (64-bit: 1 sign + 11 exponent + 52 mantissa).
Boolean Algebra & Logic Gates
George Boole's algebra of True (1) and False (0) is the logical foundation of every digital circuit and every conditional statement in a program.
OR ( + )
Logical addition — output is 1 if any input is 1.
AND ( . )
Logical multiplication — output is 1 only if all inputs are 1.
NOT ( ‾ )
Logical negation — a unary operator that flips the single input.
Truth Tables
| A | B | A + B (OR) | A . B (AND) | Ā (NOT A) |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 |
Universal Gates
NAND ( Ā.B̄ style )
AND followed by NOT. Output is 0 only when all inputs are 1 — otherwise 1.
NOR
OR followed by NOT. Output is 1 only when all inputs are 0 — otherwise 0.
NAND and NOR are called Universal Gates — any logic gate (AND, OR, NOT) can be built using only NAND gates, or only NOR gates. This simplifies manufacturing, since a chip only needs one type of gate.
De Morgan's Theorems
First Theorem
(A + B)‾ = Ā . B̄ — the complement of a sum equals the product of the complements.
Second Theorem
(A . B)‾ = Ā + B̄ — the complement of a product equals the sum of the complements.
Key Boolean Laws
| Law | Statement 1 | Statement 2 |
|---|---|---|
| Idempotent | A + A = A | A . A = A |
| Commutative | A + B = B + A | A . B = B . A |
| Associative | A+(B+C)=(A+B)+C | A.(B.C)=(A.B).C |
| Distributive | A.(B+C)=A.B+A.C | A+(B.C)=(A+B).(A+C) |
| Absorption | A+(A.B)=A | A.(A+B)=A |
Quick Recap
Tap a question to reveal the answer.
Why does binary matter more than decimal inside a computer?
Computer processors are built from transistors that have two electronic states — high (ON) and low (OFF) — naturally represented by 1 and 0. Binary is the system computers actually process internally; decimal and hexadecimal are for human convenience.
Why is hexadecimal useful even though computers don't use it internally?
Each hexadecimal digit represents exactly 4 binary bits (since 2⁴ = 16), so long binary numbers can be written in a much shorter, more readable form — useful for memory addresses and colour codes.
What problem does 2's Complement solve that Sign & Magnitude and 1's Complement don't?
Both Sign & Magnitude and 1's Complement have two representations for zero (+0 and −0), wasting a bit pattern. 2's Complement has only one representation for zero, and lets addition hardware handle subtraction too.
What are the three parts of an IEEE 754 floating-point number?
Sign bit (positive/negative), Exponent (position of the binary point), and Mantissa (the actual significant digits of the number).
State De Morgan's two theorems.
(A + B)‾ = Ā . B̄ — the complement of a sum is the product of the complements. (A . B)‾ = Ā + B̄ — the complement of a product is the sum of the complements.
Why are NAND and NOR called "Universal Gates"?
Because any basic logic gate — AND, OR, or NOT — can be constructed using only NAND gates, or only NOR gates. This simplifies circuit manufacturing since only one gate type is needed.
How does Unicode improve on ASCII?
ASCII (7-bit, later 8-bit extended) can represent at most 256 characters — enough for English but not the world's scripts. Unicode assigns a unique code point to every character across all languages, symbols and emojis, and is commonly encoded as UTF-8, UTF-16 or UTF-32.