Computer Science · Base-16
Hex
Calculator
Add, subtract, multiply and divide hexadecimal numbers. Convert hex to decimal, binary, octal. Includes a live RGB hex color tool and hex reference table.
—
Hex Result
—
Decimal
—
Binary
Hexadecimal Arithmetic
HEX
HEX
Hex ↔ Decimal / Binary / Octal
HEX
DEC
🎨 Hex Color Tool
HEX
css: color: #FF6B2B; | rgb(255, 107, 43)
Hexadecimal
—
Decimal
—
Binary
—
Octal
—
📋 Hex Reference Table (0–255)
| Dec | Hex | Dec | Hex | Dec | Hex | Dec | Hex |
|---|
Understanding Hexadecimal Numbers
Hexadecimal (base-16) uses digits 0–9 and letters A–F. It is preferred over binary in computing because each hex digit maps to exactly 4 binary bits, making it a compact representation. Memory addresses, RGB colors, and machine code are commonly written in hex.
Conversion Formulas
Hex → Decimal: each digit × 16^position
0xFF = 15×16 + 15×1 = 240 + 15 = 255
Decimal → Hex: divide by 16, record remainders
255 → 255÷16=15r15 → F×16+F = FF
Hex → Binary: each digit → 4 bits
F = 1111, A = 1010, 0xFF = 11111111
Why is hex used in web colors?
HTML/CSS colors use hex because each color channel (R, G, B) is 8 bits (0–255), which maps to exactly two hex digits (00–FF). So #FF6B2B means R=255, G=107, B=43. This is more compact than writing rgb(255,107,43) and maps directly to memory storage.
What is 0x prefix in programming?
The 0x prefix (e.g., 0xFF) is a programming convention to indicate a hexadecimal literal. In C, Python, JavaScript, and most other languages, 0xFF equals the decimal 255. Other conventions include #FF (CSS/HTML) and &FF (BASIC).
How do I add hex numbers manually?
Add digit by digit right-to-left like decimal, but carries happen when the sum exceeds 15 (F). Example: A + 7 = 17 decimal = 11 hex (write 1, carry 1). Example: FF + 01 = 100 (256 decimal).