Hex Calculator

Convert between hexadecimal and decimal or perform hex arithmetic with step-by-step results. See the complete solution with step-by-step working and formula explanations.

#

Enter your values above to see the results.

Tips & Notes

  • Each hex digit represents exactly 4 binary bits (a nibble). FF₁₆ = 11111111₂. To convert hex to binary: replace each digit with its 4-bit equivalent. A=1010, B=1011, C=1100, D=1101, E=1110, F=1111.
  • 0x prefix means hexadecimal in most programming languages: 0xFF = 255, 0x1A = 26, 0x00 = 0. In HTML/CSS, colors use # prefix instead: #FF5733. Both represent the same hex values.
  • A=10, B=11, C=12, D=13, E=14, F=15. These are not case-sensitive: 0xff = 0xFF = 255. The digit values are what matter, not the letter case.
  • One byte (8 bits) spans 0x00 to 0xFF (0 to 255). Two bytes span 0x0000 to 0xFFFF (0 to 65535). IP addresses in hex: 192.168.1.1 = C0.A8.01.01. MAC addresses use 6 hex pairs.
  • To convert decimal to hex manually: divide by 16 repeatedly and record remainders from bottom to top. 255 ÷ 16 = 15 remainder 15 (F), then 15 ÷ 16 = 0 remainder 15 (F). Read up: FF.
  • Bitwise operations in hex are common in low-level programming. AND: 0xFF & 0x0F = 0x0F (masks lower nibble). OR: 0xF0 | 0x0F = 0xFF (sets all bits). XOR: 0xFF ^ 0x0F = 0xF0 (flips lower nibble).

Common Mistakes

  • Treating hex letters as decimal digits: F is 15 not 6, D is 13 not a letter. When reading hex values like B4 or DE, remember every letter stands for a two-digit decimal value (10-15).
  • Reading conversion remainders in the wrong order: when converting decimal to hex, write remainders from last to first (bottom to top). Reading top to bottom gives a reversed and incorrect result.
  • Confusing the 0x prefix with multiplication: 0xFF does not mean 0 times xFF. It means the number FF in base 16. The prefix is just notation — it contributes no numeric value itself.
  • CSS shorthand colors: #RGB expands to #RRGGBB by doubling each digit. #F3A becomes #FF33AA, not #0F03A0. Each single hex digit represents both nibbles of the full byte.
  • Assuming hex arithmetic carries like decimal: F + 1 = 10 in hex (not 16). Carrying happens at 16, not 10. 0xFF + 0x01 = 0x100 (256 in decimal), not 0x100 being 100.
  • Forgetting that two hex digits represent exactly one byte: 0-255 range. If a value requires more than two digits (like 0x100), it no longer fits in a single byte — important in memory and color calculations.

Hex Calculator Overview

Hexadecimal (base 16) is the numeral system that uses sixteen digits: 0–9 and A–F, where A=10, B=11, C=12, D=13, E=14, F=15. Hex is the standard notation in computer science for representing binary data compactly — each hex digit corresponds to exactly four binary bits (a nibble), making the conversion between hex and binary instant without arithmetic. Memory addresses, color codes, character encodings, machine code, and network addresses are all displayed in hexadecimal.

Hex digits and their decimal equivalents:

0=0, 1=1, 2=2, 3=3, 4=4, 5=5, 6=6, 7=7, 8=8, 9=9, A=10, B=11, C=12, D=13, E=14, F=15
Hex to Decimal conversion — multiply each digit by its power of 16:
EX: 2AF₁₆ = 2×16² + 10×16¹ + 15×16⁰ = 2×256 + 10×16 + 15×1 = 512+160+15 = 687
EX: FF₁₆ = 15×16 + 15 = 255 | 100₁₆ = 1×256 = 256 | FFFF₁₆ = 65535
Decimal to Hex conversion — divide repeatedly by 16, read remainders bottom-to-top:
EX: 687 ÷ 16 = 42 R15(F) → 42 ÷ 16 = 2 R10(A) → 2 ÷ 16 = 0 R2 → read upward: 2AF₁₆
Hex to Binary — each hex digit converts directly to exactly 4 binary bits:
EX: B4₁₆ → B=1011, 4=0100 → 10110100₂ | FA₁₆ → F=1111, A=1010 → 11111010₂
This one-to-one correspondence is why hex is universally used to represent binary data — it compresses 8-bit bytes into two hex digits, making memory dumps, color codes, and machine code readable. Web colors in hex: #RRGGBB format. Each pair (00–FF) sets the intensity of Red, Green, Blue from 0 to 255. #FF0000=pure red, #00FF00=pure green, #0000FF=pure blue. #FFFFFF=white (all max), #000000=black (all zero). #808080=medium gray (128,128,128). Hex arithmetic — same as decimal but carry at 16: A+7=17=11₁₆ (write 1 carry 1). FF+1=100₁₆=256. Common hex values: 0x0F=15, 0xFF=255, 0x100=256, 0xFFFF=65,535, 0x10000=65,536, 0xFFFFFF=16,777,215 (total web colors). Programming notation: 0x prefix in C, Java, Python, JavaScript signals hex: 0xFF, 0x1A3F. # prefix in CSS web colors. 0x and # represent the same hexadecimal value in different contexts. Hexadecimal's dominance in computing stems from one elegant property: each hex digit maps exactly to four binary bits. Converting binary to hex requires no arithmetic — just group bits in fours and substitute. The byte 11010110₂ becomes D6₁₆ instantly: 1101 = D and 0110 = 6.

Frequently Asked Questions

Hexadecimal (base 16) uses sixteen digits: 0–9 and A–F, where A=10, B=11, C=12, D=13, E=14, F=15. Each hex digit represents exactly 4 binary bits, making hex a compact shorthand for binary data. To convert hex to decimal: multiply each digit by its positional power of 16. 2F₁₆ = 2×16¹ + 15×16⁰ = 32 + 15 = 47₁₀. To convert decimal to hex: divide by 16 repeatedly, collect remainders as hex digits. 255 ÷ 16 = 15 r15 → FF₁₆.

Hex addition: add digits as decimals; if the sum exceeds 15, subtract 16 and carry 1. Example: A + 7 = 10+7 = 17 → write 1, carry 1 → result digit is 1 with carry. B + 5 = 11+5 = 16 → write 0, carry 1 → result digit is 0 with carry. Full example: 1A + 2F = ? A+F = 10+15 = 25 → 25−16=9, carry 1. 1+2+1(carry) = 4. Result: 49₁₆ = 73₁₀. Verify: 26₁₀ + 47₁₀ = 73₁₀ ✓.

Hexadecimal is preferred in computing because one hex digit represents exactly 4 binary bits — a clean, compact mapping. A single byte (8 bits) is always two hex digits: 11111111₂ = FF₁₆ = 255₁₀. Memory addresses, machine code, color codes, cryptographic hashes, and network MAC addresses all use hex because it is human-readable while mapping directly to binary hardware data. Writing 0xFF is far cleaner than 11111111 or 255 when communicating with hardware registers.

Hex subtraction uses borrowing at 16. When the top digit is less than the bottom: borrow 1 from the left, adding 16 to the current position. Example: 3A − 1F. A − F: A=10, F=15, 10 < 15, borrow → 10+16=26 − 15 = 11 = B. Then 3−1−1(borrow)=1. Result: 1B₁₆. Verify: 58₁₀ − 31₁₀ = 27₁₀ = 1×16+11 = 1B₁₆ ✓. The mechanics are identical to decimal subtraction — only the borrowing adds 16 instead of 10.

Memory address FF₁₆ = 255₁₀. Address FFFF₁₆ = 65,535₁₀ — the maximum for a 16-bit system. FFFFFFFF₁₆ = 4,294,967,295₁₀ = 4 GB − 1 — the maximum address for a 32-bit system. This is why early 32-bit operating systems were limited to 4 GB of RAM. FFFFFFFFFFFFFFFF₁₆ = 2⁶⁴ − 1 ≈ 18.4 × 10¹⁸ — the 64-bit address space, allowing virtually unlimited memory addressing for modern systems.

Web colors are specified as 6 hex digits: #RRGGBB. Each pair represents one color channel from 00 (0) to FF (255). #FF0000 = pure red (R=255, G=0, B=0). #00FF00 = pure green. #0000FF = pure blue. #FFFF00 = yellow (red + green). #FFFFFF = white (all channels maximum). #000000 = black (all channels zero). Short form: #RGB where each digit is doubled — #F00 = #FF0000. Converting hex colors to decimal gives the exact RGB values used in image processing and graphics rendering.