How to use the hex calculator
- Enter two hex numbers, for example
8ABandB78. A minus sign and prefixes such as0xare allowed. - Pick the operation. The result updates instantly in hex, decimal and binary; division also shows the remainder.
- For negative results and NOT, choose the bit width (8, 16, 32 or 64 bits) to see the two's-complement value.
How to add hex numbers
Add the digits column by column from the right, exactly as in decimal. The only difference: when a column adds up to 16 or more, write down the sum minus 16 and carry 1 to the next column. Example: 8AB + B78.
| Column | Digits | Sum | Write | Carry |
|---|---|---|---|---|
| 16⁰ | B + 8 | 11 + 8 = 19 | 3 | 1 |
| 16¹ | A + 7 + 1 | 10 + 7 + 1 = 18 | 2 | 1 |
| 16² | 8 + B + 1 | 8 + 11 + 1 = 20 | 4 | 1 |
| 16³ | carry | 1 | 1 | – |
Reading the written digits from the bottom row up (highest column first) gives 1423. Check in decimal: 2219 + 2936 = 5155 = 1423 hex.
Hex subtraction, negative results and two's complement
Subtraction works with borrowing: if the top digit is smaller, borrow 16 from the next column. B78 − 8AB: 8 − B needs a borrow, 8 + 16 − 11 = 13 = D; then 7 − 1 − A needs a borrow, 6 + 16 − 10 = 12 = C; finally B − 1 − 8 = 2, so the result is 2CD.
If the second number is larger, the result is negative. The calculator shows it with a minus sign (5 − 8 = −3) and also as the bit pattern a computer stores: in 8-bit two's complement −3 is 2⁸ − 3 = 253 = FD, in 16 bits FFFD. By hand, negate a number by inverting all bits and adding 1: 03 = 0000 0011 → 1111 1100 → 1111 1101 = FD.
Bitwise operations: AND, OR, XOR, NOT and shifts
Bitwise operations compare the numbers bit by bit, which is why programmers use them for flags, masks and permissions. Examples with 3C = 0011 1100 and 0F = 0000 1111:
| Operation | Rule | Result |
|---|---|---|
3C AND 0F | 1 only where both bits are 1 | 0C |
3C OR 0F | 1 where at least one bit is 1 | 3F |
3C XOR 0F | 1 where the bits differ | 33 |
NOT 3C (8-bit) | every bit flipped | C3 |
3C << 1 | shift left = multiply by 2 | 78 |
3C >> 2 | shift right = divide by 4 | 0F |
Frequently asked questions
How do you multiply hex numbers?
The same way as in decimal, but every partial product is written in base 16. It is often easier to convert to decimal, multiply and convert back: 1A × 10 = 26 × 16 = 416 = 1A0. Multiplying by 10 hex (16) simply appends a zero, just like multiplying by 10 in decimal.
What happens when I divide hex numbers?
The calculator performs integer division and shows the quotient and the remainder: 1423 ÷ 10 = 142 remainder 3. Dividing by zero is reported as an error.
Why does NOT give different results for different bit widths?
NOT flips every bit of a fixed-size value, so the result depends on how many bits there are: NOT 3C is C3 in 8 bits but FFC3 in 16 bits. Auto width picks the smallest standard width (8, 16, 32 or 64 bits) that holds the number.
Can the hex calculator handle large numbers?
Yes. All operations use arbitrary-precision integers, so 64-bit, 128-bit and even longer values are calculated exactly, without the overflow or rounding of an ordinary calculator.