Add, subtract, multiply or divide hex, use AND, OR, XOR and shifts, or convert to decimal and binary. The answer updates as you type.
Private by design. Everything runs in your browser and is never uploaded.
A hex calculator does arithmetic on hexadecimal (base 16) numbers, which use the digits 0 to 9 and the letters A to F. Enter two hex numbers, pick an operation, and the result appears in hex, decimal and binary with steps. For example, 8AB + B78 = 1423 in hex, which is 2219 + 2936 = 5155 in decimal.
This hex calculator also handles negative numbers, division with a remainder, AND, OR, XOR, NOT and shifts, and a two’s complement view for a bit width you choose. A second mode converts hex to decimal, decimal to hex and hex to binary with the working written out. Results change as you type, and nothing leaves your browser. For other everyday sums, see the free online calculators.
| Calculation (hex) | Answer (hex) | Same in decimal |
|---|---|---|
| 8AB + B78 | 1423 | 2219 + 2936 = 5155 |
| 5DC − 3AF | 22D | 1500 − 943 = 557 |
| FA × C3 | BE6E | 250 × 195 = 48750 |
| FF ÷ 10 | F remainder F | 255 ÷ 16 = 15 remainder 15 |
| 5 − A | −5 | 5 − 10 = −5 |
| FF AND 0F | 0F | 255 AND 15 = 15 |
| NOT 0F (8-bit) | F0 | NOT 15 = 240 (8-bit) |
| 1 << 4 | 10 | 1 × 16 = 16 |
The first answer is already on screen. Change any number and it updates at once, with no Calculate button.
Enter digits 0 to 9 and A to F in either case. A leading 0x, # or $, a trailing h, spaces and underscores are all accepted, and a minus sign makes the number negative. On a phone, the Hex keypad button gives you digits and letters on one screen.
Choose add, subtract, multiply, divide or mod, or switch to AND, OR, XOR, NOT and the left and right shifts. Enter the second number, or the number of bits for a shift.
The result is shown in hex, decimal and binary. Division gives the quotient and the remainder together. Pick a bit width of 8, 16, 32 or 64 to see the two’s complement pattern, or leave it on Auto.
Open the step-by-step working to see carries, borrows, partial products or long division for your own numbers. Use Convert mode for place values, repeated division and the four-bit table, then copy the answer or share a link.
Hex arithmetic follows the same column method as decimal, except that a column holds 16 values instead of 10. The letters A to F stand for 10 to 15, so B + 8 is 11 + 8 = 19 in decimal, which is 13 in hex: write 3 and carry 1. When a digit is too small to subtract, borrow 16 from the next column instead of 10.
Multiplication works digit by digit with each partial product shifted one place left, and division is long division in base 16, where each quotient digit is a value from 0 to F. Because one hex digit is exactly four bits (a nibble), hex is also a short way to write binary, which is why it is used for memory addresses, colours and bit masks. Converting a whole text to bits is a different job, handled by the text to binary translator.
| Operation | Rule |
|---|---|
| Add | Add each column plus the carry. If the total is 16 or more, write the total minus 16 and carry 1. |
| Subtract | Subtract each column minus the borrow. If it is below 0, add 16 and borrow 1 from the next column. |
| Multiply | Multiply by each digit of the second number, shift each product one place left, then add the products. |
| Divide | Long division in base 16. The quotient and the remainder satisfy quotient × divisor + remainder = dividend. |
| Hex to decimal | Multiply each digit by 16 to the power of its place (0 at the right) and add. |
| Decimal to hex | Divide by 16 repeatedly and read the remainders from last to first. |
| Hex to binary | Replace each hex digit with its four bits. Reverse it by grouping bits in fours from the right. |
| Two’s complement | For a negative number, flip the bits of its size and add 1, within a fixed number of bits. |
Keep these open while you work by hand. Every value was calculated, not copied.
| Hex | Decimal | Binary (4 bits) |
|---|---|---|
| 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 |
| Power | Decimal value | In hex |
|---|---|---|
| 160 | 1 | 1 |
| 161 | 16 | 10 |
| 162 | 256 | 100 |
| 163 | 4,096 | 1000 |
| 164 | 65,536 | 10000 |
| 165 | 1,048,576 | 100000 |
| 166 | 16,777,216 | 1000000 |
| 167 | 268,435,456 | 10000000 |
| 168 | 4,294,967,296 | 100000000 |
| × | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
| 2 | 2 | 4 | 6 | 8 | A | C | E | 10 | 12 | 14 | 16 | 18 | 1A | 1C | 1E |
| 3 | 3 | 6 | 9 | C | F | 12 | 15 | 18 | 1B | 1E | 21 | 24 | 27 | 2A | 2D |
| 4 | 4 | 8 | C | 10 | 14 | 18 | 1C | 20 | 24 | 28 | 2C | 30 | 34 | 38 | 3C |
| 5 | 5 | A | F | 14 | 19 | 1E | 23 | 28 | 2D | 32 | 37 | 3C | 41 | 46 | 4B |
| 6 | 6 | C | 12 | 18 | 1E | 24 | 2A | 30 | 36 | 3C | 42 | 48 | 4E | 54 | 5A |
| 7 | 7 | E | 15 | 1C | 23 | 2A | 31 | 38 | 3F | 46 | 4D | 54 | 5B | 62 | 69 |
| 8 | 8 | 10 | 18 | 20 | 28 | 30 | 38 | 40 | 48 | 50 | 58 | 60 | 68 | 70 | 78 |
| 9 | 9 | 12 | 1B | 24 | 2D | 36 | 3F | 48 | 51 | 5A | 63 | 6C | 75 | 7E | 87 |
| A | A | 14 | 1E | 28 | 32 | 3C | 46 | 50 | 5A | 64 | 6E | 78 | 82 | 8C | 96 |
| B | B | 16 | 21 | 2C | 37 | 42 | 4D | 58 | 63 | 6E | 79 | 84 | 8F | 9A | A5 |
| C | C | 18 | 24 | 30 | 3C | 48 | 54 | 60 | 6C | 78 | 84 | 90 | 9C | A8 | B4 |
| D | D | 1A | 27 | 34 | 41 | 4E | 5B | 68 | 75 | 82 | 8F | 9C | A9 | B6 | C3 |
| E | E | 1C | 2A | 38 | 46 | 54 | 62 | 70 | 7E | 8C | 9A | A8 | B6 | C4 | D2 |
| F | F | 1E | 2D | 3C | 4B | 5A | 69 | 78 | 87 | 96 | A5 | B4 | C3 | D2 | E1 |
A basic hex calculator takes two numbers and gives one answer. These are the details that make the answer easier to trust and to use.
| Feature | Basic hex calculator | This calculator |
|---|---|---|
| Results | Often needs a Calculate button | Updates as you type, with an answer on first load |
| Working | Answer only, or fixed examples | Carries, borrows, partial products and long division for your own numbers |
| Division | Quotient only | Quotient and remainder, with a check that quotient × divisor + remainder returns the start |
| Negative numbers | Often missing or unexplained | Minus sign supported, plus a two’s complement view for 8, 16, 32 or 64 bits |
| Bitwise | A separate tool, if any | AND, OR, XOR, NOT and shifts with an aligned bit table |
| Conversion | One output base | Hex, decimal, binary and octal together, with place-value and four-bit tables |
| Input | Digits only | Accepts 0x, #, $, a trailing h, spaces and underscores, and explains any non-hex character |
| Size | May stop at 32 or 64 bits | Exact for up to 4,096 hex digits per number |
| On a phone | Switch between letter and number keyboards | Optional on-screen hex keypad and large tap targets |
| Sharing | Rare | Copy the answer or a summary, or share a link with the same numbers |
Add an offset to a base address, or subtract two addresses to find a size. The decimal row confirms the distance in bytes.
AND tests a flag, OR sets it and XOR toggles it. The aligned bit table shows exactly which bits changed.
Check a negative offset or an overflow with the two’s complement view in 8, 16, 32 or 64 bits, and see where a value wraps around.
A web colour such as FF8800 is three hex pairs. Convert each pair to decimal in Convert mode to get 255, 136 and 0.
The written steps let you compare your own working with a correct one. Save the result in the online notepad if you want to keep it.
To turn words into bits, use the text to binary translator, and to read bits back as words use the binary to text converter.
A few rules explain most of the surprises people meet with hexadecimal, especially around negative numbers and bit widths.
ff, FF and 0xFF are the same number. The 0x prefix and lower case switches only change how the answer is written, and they are remembered on your device.
-7 divided by 2 gives a quotient of -3 and a remainder of -1, the same as in C and JavaScript. The remainder takes the sign of the first number.
On paper a negative number is just a minus sign. In hardware it is a fixed number of bits, so -5 is FB in 8 bits and FFFB in 16 bits. Pick a width to see each pattern.
NOT and the two’s complement view use the smallest number of whole bytes that holds your number, so NOT 0F is F0 and NOT 1FF is FE00.
A positive number is filled with zeros on a right shift, and a negative number is filled with copies of its sign bit. A left shift by n multiplies by 2 to the power n unless bits fall off the width.
The maths uses whole-number arithmetic, so long numbers are never rounded, and nothing you type leaves your browser. For rounding a decimal answer, use the rounding calculator.
Hex fractions such as 1.8 and floating-point formats are not supported. For ordinary decimal fractions, see the fraction calculator.
Programming languages differ in how they treat overflow, signed shifts and integer sizes. Choose a bit width to mimic a fixed-size type, then confirm the behaviour in your own language or hardware manual.
Each number can have up to 4,096 digits and a shift can move up to 4,096 bits. The notation guide on Wikipedia lists other prefixes and suffixes that are not read here.
The calculations are exact whole-number arithmetic, checked against the worked examples on this page and against independent decimal calculations. The definitions come from these references.
Short answers to common questions about hexadecimal maths.
A hex calculator does arithmetic on hexadecimal (base 16) numbers, which use the digits 0 to 9 and the letters A to F. It adds, subtracts, multiplies and divides them and shows the answer in hex, decimal and binary.
Add the digits column by column from the right, and when a column totals 16 or more, write the total minus 16 and carry 1 to the next column. For example, 8AB + B78 = 1423 in hex, because 2219 + 2936 = 5155 in decimal.
Subtract column by column from the right, and borrow 16 from the next column when a digit is too small. For example, 5DC − 3AF = 22D, and when the second number is larger the answer is negative, so 5 − A = −5.
Multiply the first number by each digit of the second, shift each product one more place to the left, then add the products. For example, FA × C3 = BE6E, which is 250 × 195 = 48750 in decimal.
Use long division in base 16. The calculator gives the quotient and the remainder together, for example FF ÷ 10 = F remainder F, which is 255 ÷ 16 = 15 remainder 15 in decimal. Division rounds toward zero, and the remainder takes the sign of the first number.
Multiply each digit by 16 raised to its place, counting from 0 at the right, and add the results. For DAD that is 13 × 256 + 10 × 16 + 13 = 3501.
Divide the number by 16 again and again and write down each remainder, then read the remainders from the last to the first. For 170, 170 ÷ 16 = 10 remainder 10 and 10 ÷ 16 = 0 remainder 10, so the answer is AA.
Type a minus sign in front, such as -1A, and the answer keeps the sign. For fixed-width work the result also shows the two’s complement pattern in the bit width you pick, so −5 is FB as an 8-bit value.
No. Case does not change the value, so ff and FF are the same number, and you can type 0x, # or $ in front or h after the number. The 0x prefix and lower case switches only change how the answer is written.
Each hex digit is four bits and the operation is applied to every bit, so FF AND 0F = 0F, F0 OR 0F = FF and AA XOR FF = 55. NOT and shifts depend on the bit width, so pick 8, 16, 32 or 64 bits, or leave Auto to use the smallest whole number of bytes.
Each number can have up to 4,096 hex digits and the answers are exact, because the maths uses whole numbers with no rounding. Only whole numbers are supported, so hex fractions such as 1.8 are not.
No. The calculation runs in your browser and nothing is sent to a server. The numbers appear in the page address only so a shared link opens with the same values, and your 0x prefix and lower case choices are remembered on your own device.