Skip to content
Calculator.hair

Hex Calculator

Hexadecimal Calculation—Add, Subtract, Multiply, or Divide

Press Calculate to see the results.

Convert Hexadecimal Value to Decimal Value

Press Calculate to see the results.

Convert Decimal Value to Hexadecimal Value

Press Calculate to see the results.

This hex calculator does arithmetic on base-16 numbers and converts values between hexadecimal and decimal. Letters A–F may be typed in upper or lower case.

The hexadecimal system, usually shortened to hex, is base 16. It needs sixteen digits, so after 0 through 9 it borrows the letters A through F to stand for the values ten through fifteen. Each place in a hex number is worth sixteen times the place to its right: ones, sixteens, 256s, 4,096s and so on.

Hex is popular in computing because it is a compact way to write binary. Since 16 = 2⁴, each hex digit corresponds to exactly four bits, so a byte is always two hex digits and a 32-bit value is eight. The byte 10101010 splits into 1010 and 1010, which are A and A, so it is written AA in hex. You see hex in web colors such as #0F766E, in memory addresses, in MAC addresses and in Unicode code points like U+00E9.

HexBinaryDecimal
000
111
2102
3113
41004
51015
61106
71117
810008
910019
A101010
B101111
C110012
D110113
E111014
F111115
101000016
FF11111111255
100100000000256

To convert hex to decimal, multiply each digit's value by its power of 16 and add the results. For 2AA: (2 × 16²) + (10 × 16¹) + (10 × 16⁰) = 512 + 160 + 10 = 682. For DAD, the converter's default: (13 × 256) + (10 × 16) + (13 × 1) = 3,328 + 160 + 13 = 3,501.

To convert decimal to hex, find how many times the largest suitable power of 16 fits, record that digit, and repeat with the remainder. Take 1,500. The largest power of 16 not exceeding it is 256, and 256 fits 5 times (1,280), leaving 220. Next, 16 fits into 220 thirteen times (208), leaving 12. Thirteen is D and twelve is C, so 1,500 = 5DC.

The repeated-division method gives the same digits from the other end. Divide by 16 and keep the remainder as the lowest digit, then divide the quotient again: 1,500 ÷ 16 = 93 remainder 12 (C), 93 ÷ 16 = 5 remainder 13 (D), 5 ÷ 16 = 0 remainder 5. Reading upward gives 5DC. The converter above shows these steps.

Hex and binary convert into each other directly, four bits at a time, with no arithmetic beyond memorizing the sixteen patterns in the table. 5DC becomes 0101 1101 1100, and the binary 1111 0000 becomes F0. This is the main reason programmers prefer hex to decimal when looking at raw data.

Hex Addition

Hex addition uses the column method with carrying, except that a column carries when its total reaches 16 rather than 10. It often helps to translate each digit to decimal, add, and translate back. If the column total is 16 or more, subtract 16, write the remainder as a hex digit and carry 1.

Take the default sum 8AB + B78. Rightmost column: B + 8 = 11 + 8 = 19, which is 16 + 3, so write 3 and carry 1. Middle column: A + 7 + 1 = 10 + 7 + 1 = 18, which is 16 + 2, so write 2 and carry 1. Left column: 8 + B + 1 = 8 + 11 + 1 = 20, which is 16 + 4, so write 4 and carry 1. The final carry becomes a new leading digit, giving 1423. In decimal, 2,219 + 2,936 = 5,155, and 1423 hex is 4,096 + 1,024 + 32 + 3 = 5,155.

Hex Subtraction

Hex subtraction works column by column from the right. When the top digit is smaller than the bottom one, borrow 1 from the next column to the left. Because that place is worth sixteen of the current one, the borrow adds 16 to the top digit rather than 10.

For example, B78 − 8AB. Rightmost column: 8 − B is 8 − 11, which is negative, so borrow. The 8 becomes 8 + 16 = 24, and 24 − 11 = 13, written D. The middle column's 7 has lent 1, so it is now 6, and 6 − A = 6 − 10 is negative again; borrow, making it 22, and 22 − 10 = 12, written C. The left column's B has lent 1 and is now A, and A − 8 = 2. The answer is 2CD. Checking in decimal: 2,936 − 2,219 = 717, and 2CD = 512 + 192 + 13 = 717.

If the second number is larger than the first, swap them, subtract, and mark the result negative. In computers, hex values are often fixed-width, and negative numbers are stored in two's complement; for an 8-bit value, −1 is FF.

Hex Multiplication

Multiplying in hex follows ordinary long multiplication: multiply the top number by each digit of the bottom number, shift each partial product one place left for each position, and add. The single-digit products are the tricky part; convert to decimal, multiply, and convert back, or use the multiplication table below. For instance B × 7 = 11 × 7 = 77 = 4 × 16 + 13, so write D and carry 4. As a full example, 2A × 13 = 42 × 19 = 798 in decimal, which is 31E in hex.

Hex Division

Hex long division works the same way as decimal long division with base-16 arithmetic at each step. Bring down digits until the divisor fits, find how many times it fits (a single hex digit from 0 to F), multiply, subtract and continue. Converting the step products to decimal keeps the arithmetic manageable. For example, 5DC ÷ C is 1,500 ÷ 12 = 125, which is 7D in hex. This calculator gives the whole-number quotient and the remainder.

7DC5DC−549C−9C0

Hexadecimal Multiplication Table

Products of the hex digits 1 through F, written in hex. Each entry is the row value times the column value; for example, row A and column C give 78, which is 10 × 12 = 120 in decimal.

×123456789ABCDEF
1123456789ABCDEF
22468ACE10121416181A1C1E
3369CF1215181B1E2124272A2D
448C1014181C2024282C3034383C
55AF14191E23282D32373C41464B
66C12181E242A30363C42484E545A
77E151C232A31383F464D545B6269
881018202830384048505860687078
99121B242D363F48515A636C757E87
AA141E28323C46505A646E78828C96
BB16212C37424D58636E79848F9AA5
CC1824303C4854606C7884909CA8B4
DD1A2734414E5B6875828F9CA9B6C3
EE1C2A38465462707E8C9AA8B6C4D2
FF1E2D3C4B5A69788796A5B4C3D2E1

Frequently asked questions

What does the letter A mean in hex?

A is the hex digit for ten. B is eleven, C twelve, D thirteen, E fourteen and F fifteen.

How do I convert hex to decimal?

Multiply each digit by its power of 16 and add. 1F = 1 × 16 + 15 = 31.

How do I convert hex to binary?

Replace each hex digit with its four-bit pattern. 3C becomes 0011 1100.

Why is hex used for colors?

A web color stores red, green and blue as one byte each, and two hex digits write one byte neatly, so #FF8800 means red 255, green 136, blue 0.

Updated by Calculator.hair. How we build and check our calculators