Why Binary and Hexadecimal Matter
Computers store and process all data as binary — sequences of 0s and 1s. Every number, character, image, and instruction is ultimately a pattern of bits. Binary is the native language of the hardware.
Hexadecimal (base 16) is a human-friendly way to represent binary data. Because 16 = 2⁴, each hex digit corresponds to exactly four binary bits. A byte (8 bits) is represented by exactly two hex digits. This makes hex much more compact and readable than binary for memory addresses, color codes, and data dumps.
Common places you encounter hex in programming:
- CSS color codes:
#FF6B35— each pair of hex digits is the red, green, and blue value (0–255) - Memory addresses in debuggers:
0x7fff5fbff8e8 - Character encoding: Unicode code points like U+1F600 (😀)
- Network MAC addresses:
00:1B:44:11:3A:B7 - SHA hashes:
a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3
Binary Addition
Binary addition follows the same algorithm as decimal addition, with carries:
- 0 + 0 = 0
- 0 + 1 = 1
- 1 + 0 = 1
- 1 + 1 = 10 (0 with carry 1)
- 1 + 1 + 1 (with carry) = 11 (1 with carry 1)
Example: Add 1011 (11) and 0110 (6):
1011 (11)
+ 0110 ( 6)
------
10001 (17)
Working right to left: 1+0=1, 1+1=10 (write 0, carry 1), 0+1+1=10 (write 0, carry 1), 1+0+1=10 (write 0, carry 1), 0+0+1=1. Result: 10001 = 16+1 = 17. ✓
Binary Subtraction
Binary subtraction can be done directly using borrowing (like decimal subtraction), but in digital systems it is more commonly performed using two's complement — which converts subtraction into addition.
Two's complement of a binary number: flip all bits, then add 1.
To compute 1010 (10) − 0011 (3):
- Two's complement of 0011: flip → 1100, add 1 → 1101
- Add: 1010 + 1101 = 10111
- Ignore the overflow bit: 0111 = 7. ✓ (10 − 3 = 7)
Hexadecimal Addition
Hex addition works like decimal but with 16 digits (0–9, A–F). A carry occurs when the sum exceeds 15 (F).
Add 0x2A and 0x1F:
2A (42)
+ 1F (31)
----
49 (73)
A + F = 10 + 15 = 25 = 16 + 9, so write 9 and carry 1. 2 + 1 + 1 (carry) = 4. Result: 0x49 = 4×16 + 9 = 64 + 9 = 73. ✓
Bitwise Operations
In addition to arithmetic, binary operations include bitwise operations used in programming:
- AND (&): Both bits must be 1: 1010 & 1100 = 1000
- OR (|): Either bit can be 1: 1010 | 1100 = 1110
- XOR (^): Bits must be different: 1010 ^ 1100 = 0110
- NOT (~): Flip all bits: ~1010 = 0101
- Left shift (<<): Multiply by powers of 2: 0001 << 3 = 1000 (1 × 8 = 8)
- Right shift (>>): Divide by powers of 2: 1000 >> 2 = 0010 (8 ÷ 4 = 2)
These operations are fundamental to image processing, network programming, cryptography, and performance-critical code. Use our Binary / Hex Calculator to perform arithmetic on binary and hex values directly without converting to decimal first.
Calculate in binary and hex — free
Add, subtract, and convert between binary, hex, and decimal instantly.Frequently Asked Questions
Why do computers use binary?
Computer hardware is built from transistors that have two states: on (1) and off (0). Binary directly maps to these physical states. Using decimal would require distinguishing ten different voltage levels, which is much harder to implement reliably in electronic circuits.
Why do programmers use hexadecimal instead of binary?
A 32-bit binary number like 11111111111111111111111111111111 is hard to read. In hexadecimal, that same number is FFFFFFFF — far more compact and readable. Each hex digit corresponds to exactly 4 binary bits, making conversion between them trivial.
What is a bit, a byte, and a nibble?
A bit (binary digit) is a single 0 or 1. A byte is 8 bits and can represent 256 values (0–255). A nibble is 4 bits and represents a single hex digit (0–F). These are the fundamental units of digital storage and memory addressing.
How do you add binary numbers?
Binary addition works like decimal addition but with only two digits. 0+0=0, 0+1=1, 1+0=1, 1+1=10 (0 carry 1). Example: 1011 + 0110 = 10001 (11 + 6 = 17 in decimal). The carry propagation is the same as in decimal arithmetic.
← Back to Blog | Related tool: Binary / Hex Calculator