Hex Calculator

About this calculator

The Hex Calculator adds, subtracts, multiplies and divides hexadecimal (base 16) numbers and shows each answer in hex and in decimal with the working. It also converts hex to decimal and decimal to hex.

Values can be as long as you like because calculations use exact big-integer arithmetic.

Digits 0 to 9 and letters A to F. A leading minus sign is allowed.
Whole numbers; any fractional part is dropped.
Embed this calculator

Paste this code into a Custom HTML block on your site. The calculator fits the width of the block. Adjust the height in the code if you want more room for results.

Find this widget in the publisher directory

What is hexadecimal?

Hexadecimal, or hex, is the base 16 number system. It needs sixteen digit symbols, so after 0 through 9 it borrows the letters A through F for the values ten through fifteen. Each place is worth sixteen times the place to its right: 1, 16, 256, 4,096 and so on. Because one hex digit stands for exactly four binary digits, hex is a compact way to write binary data. A byte is always two hex digits.

HexDecimalBinary
000000
550101
991001
A101010
B111011
C121100
D131101
E141110
F151111
101610000
3F63111111

Hex to decimal

Multiply each digit by 16 raised to its position (counting from 0 on the right) and add. For 2AA:

2AA₁₆ = 2×16² + 10×16¹ + 10×16⁰ = 512 + 160 + 10 = 682

Another check: hex 1024 is 1×4096 + 0×256 + 2×16 + 4 = 4,132.

Decimal to hex

Divide by 16 repeatedly and keep the remainders, converting 10 to 15 into A to F. The remainders read from last to first are the hex digits. For 1,500: 1,500 ÷ 16 = 93 r 12 (C), 93 ÷ 16 = 5 r 13 (D), 5 ÷ 16 = 0 r 5. Reading upward gives 5DC.

Hex addition

Add column by column from the right. If a column sum reaches 16 or more, subtract 16, write the result and carry 1. For example, B + 7 = 18 in decimal, which is 12 hex: write 2 and carry 1. Adding two longer values works exactly as in decimal, only with 16 in place of 10.

Hex subtraction

Subtract each column, borrowing 16 from the next column to the left when the top digit is smaller. Example: 5DC − 3AF. In the right column C (12) − F (15) cannot be done, so borrow 16 to get 28 − 15 = 13, which is D. The middle column is then 13 − 1 (borrowed) − 10 = 2, and the left column is 5 − 3 = 2. The answer is 22D, matching 1,500 − 943 = 557 in decimal.

Hex multiplication

Multiply the top number by each digit of the bottom number in turn, shift each partial product one place left per position, and add them in base 16. Multiplying by hex 10 simply appends a zero. Since hex digits go up to F, it helps to keep a multiplication table or to convert partial products through decimal.

Hex division

Long division works the same way as in decimal. For FACE ÷ 12, the quotient is DEF with remainder 0: 64,206 ÷ 18 = 3,567, which is DEF in hex. When the division is not exact the calculator gives a whole-number quotient and a remainder.

Where hex is used

  • Web and design colors such as #FF8800, where each pair of digits is red, green or blue from 00 to FF.
  • Memory addresses and machine code in debugging tools.
  • MAC addresses, IPv6 addresses and character codes.
  • Hash values and cryptographic keys.

Tips for working in hex

Memorize that A is 10, B is 11, C is 12, D is 13, E is 14 and F is 15, and that F plus 1 rolls over to 10. Two hex digits cover one byte, so FF is 255, the largest byte value. Converting between hex and binary is a digit-by-digit lookup: 2AA is 0010 1010 1010, which is the binary number 1010101010 with leading zeros dropped. Prefixes such as 0x or # mark a value as hexadecimal in code and in web colors, but the digits themselves are the same.

Frequently asked questions

What is 2AA in decimal?
2AA in hex is 2 × 256 + 10 × 16 + 10 = 682 in decimal.
What is 1500 in hex?
1,500 in decimal is 5DC in hexadecimal.
Is hex case sensitive?
No. The calculator accepts a to f or A to F and shows results in uppercase.
Can I enter a 0x prefix?
Yes, a leading 0x is ignored. A leading minus sign marks a negative value.

Formulas and sample results on this page were checked against independent references. Page last reviewed or updated . How we verify calculators. Project led by Shaun Connell.