Hex Calculator

Perform arithmetic on hexadecimal (base-16) numbers and convert between hex, decimal, and binary. Accepts standard hex digits 0–9 and A–F.

Advertisement
Modify the values and click Calculate

Hex Calculator — Hexadecimal Arithmetic and Conversion Guide

Hexadecimal (base-16) is the number system most commonly used by programmers and computer engineers to represent binary data compactly. You'll encounter hex in HTML colour codes, memory addresses, debugging output, cryptographic hashes, and network protocol headers. This hex calculator handles arithmetic and converts between hexadecimal, decimal, and binary in one step.

What Is Hexadecimal (Base-16)?

The hexadecimal system uses 16 distinct symbols:

  • 0–9 representing values 0 through 9 (same as decimal)
  • A–F representing values 10 through 15
Hex Decimal Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111

How to Convert Hexadecimal to Decimal

Each position in a hex number represents a power of 16. Working from right to left, the positions have values 16⁰ = 1, 16¹ = 16, 16² = 256, 16³ = 4096, and so on.

Example: Convert 2F₁₆ to decimal

  • Position 1 (rightmost): F × 16⁰ = 15 × 1 = 15
  • Position 2: 2 × 16¹ = 2 × 16 = 32
  • Total: 32 + 15 = 47₁₀

Example: Convert 1A3₁₆ to decimal

  • A × 1 = 10 × 1 = 10
  • 1 × 3 = 3 × 16 = 48
  • Wait — let's redo: 3 × 16⁰ = 3, A × 16¹ = 160, 1 × 16² = 256
  • Total: 256 + 160 + 3 = 419₁₀

How to Convert Decimal to Hexadecimal

Use repeated division by 16, recording remainders (converting values 10–15 to A–F):

Example: Convert 255₁₀ to hex

Division Quotient Remainder Hex Digit
255 ÷ 16 15 15 F
15 ÷ 16 0 15 F

Read remainders bottom to top: FF₁₆

This is why 255 in decimal is written as FF in hex — used as the maximum channel value in HTML colours.

How to Convert Hex to Binary

Since each hex digit corresponds exactly to 4 binary bits, conversion is straightforward:

Replace each hex digit with its 4-bit binary equivalent from the table above.

Example: Convert 3C₁₆ to binary

  • 3 = 0011
  • C = 1100
  • 3C₁₆ = 00111100₂ = 60₁₀

Hexadecimal Addition

Add hex digits column by column from right to left. When a column sums to 16 or more, write the remainder in hex and carry 1.

Example: 1A₁₆ + 2F₁₆

  • Rightmost: A + F = 10 + 15 = 25 = 16 + 9, write 9 carry 1
  • Next: 1 + 2 + 1 (carry) = 4
  • Result: 49₁₆ = 73₁₀ (26 + 47 = 73 ✓)

Hexadecimal in Computing

HTML and CSS Colour Codes

Web colours are written as 6 hex digits: #RRGGBB, where:

  • RR = Red channel (00–FF = 0–255)
  • GG = Green channel
  • BB = Blue channel

Examples:

  • #FFFFFF = White (255, 255, 255)
  • #000000 = Black (0, 0, 0)
  • #FF0000 = Pure Red
  • #1A73E8 = Google Blue (26, 115, 232)

Memory Addresses

Memory addresses in computer systems are almost always displayed in hex. A 64-bit address like `0x7FFE4B3A1C00` is much more readable than its decimal equivalent (140,729,736,675,328).

Hashes and Checksums

MD5 produces 32 hex characters (128 bits). SHA-256 produces 64 hex characters (256 bits). The prefix `0x` or `#` conventionally indicates a hex number.

IPv6 Addresses

IPv6 uses eight groups of 4 hex digits: `2001:0db8:85a3:0000:0000:8a2e:0370:7334`

The Relationship Between Hex and Binary

Hex is essentially a shorthand for binary. Since 16 = 2⁴, each hex digit represents exactly 4 bits. This makes hex ideal for humans reading binary data — 8 binary digits (one byte) can be expressed as exactly 2 hex digits.

4 hex digits = 16 binary digits = 2 bytes

Programmers use hex constantly when debugging because it compresses long binary strings into readable form.

Related Resources

Related Calculators

External Authority Resources

Frequently Asked Questions

Multiply each hex digit by 16 raised to its positional power (from right, starting at 0). For example, 2F₁₆ = (2 × 16¹) + (15 × 16⁰) = 32 + 15 = 47₁₀.

In hex, A=10, B=11, C=12, D=13, E=14, F=15 in decimal. These letters extend the number system to base-16 without using multi-character digits.

HTML colours use three 2-digit hex pairs for Red, Green, Blue (RGB). For example, #FF6B35 = Red: FF (255), Green: 6B (107), Blue: 35 (53) in decimal.

Each hex digit represents exactly 4 binary digits. For example, F₁₆ = 1111₂, and 2A₁₆ = 0010 1010₂. This makes hex a compact notation for binary values.

Add hex digits from right to left, just like decimal addition, but carry when the sum reaches 16 (not 10). For example, 9 + 8 = 17 = 11₁₆ (write 1, carry 1).

Advertisement