How the hex calculator works
Use Calculate for arithmetic or bitwise operations on two hexadecimal numbers. Use Convert to express one number in hexadecimal, decimal, binary and octal. The main arithmetic answer is hexadecimal; the other bases let you check the same value in a more familiar form.
- 1Choose the operation or input base. Calculate supports addition, subtraction, multiplication, division, AND, OR and XOR. In Convert, choose the base of the number you enter.
- 2Enter the numbers. Hexadecimal uses digits 0–9 and letters A–F. Use a leading minus sign for a negative value in unrestricted arithmetic, or a point for a hexadecimal fraction.
- 3Set the word size. Choose Any for arithmetic without fixed-width wrapping. Choose 8, 16, 32 or 64 bits for whole-number register calculations, then check the stored result, signed interpretation and applicable carry or overflow information.
Hexadecimal digits and place values
Hexadecimal is base 16. Letters A through F stand for decimal values 10 through 15, and uppercase and lowercase letters have the same value. Each hex digit corresponds to four binary digits, so two hex digits describe one eight-bit byte. RFC 4648 specifies this base-16 alphabet for encoding bytes.
| 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 |
Converting between number bases
To convert hex to decimal, multiply each digit's value by its power of 16 and add the products. Starting at the ones place, the integer positions have weights 1, 16, 256 and 4,096. This is the same positional method used for decimal, with a different base.
Evaluate the magnitude first, then apply any leading minus sign. Negative positions describe digits after the hexadecimal point.
For example, 1A3 in hex is 1 × 256 + 10 × 16 + 3 = 419 in decimal. Fractional positions have weights 1/16, 1/256 and so on, so hex 0.8 equals 8 ÷ 16 = 0.5 in decimal.
For decimal integers, divide repeatedly by 16 and read the remainders backward. For 419, the remainders are 3, 10 and 1, giving 1A3. For binary, replace each hex digit with four bits. For octal, regroup those bits into threes, working outward from the point.
Worked example: adding two hex numbers
Choose addition, enter 8AB and B78, and use Any word size. Work from right to left, carrying whenever a column reaches decimal 16.
- 1Add the rightmost digits. B + 8 is decimal 11 + 8 = 19. Write 3 and carry 1.
- 2Add the middle digits. A + 7 + the carry is decimal 10 + 7 + 1 = 18. Write 2 and carry 1.
- 3Finish the leftmost column. 8 + B + the carry is decimal 8 + 11 + 1 = 20. Write 4 and carry the final 1 into a new column, giving 1423.
The decimal check is 2,219 + 2,936 = 5,155. Spaces may make the binary easier to read: 1 0100 0010 0011 has the same value as the unspaced result.
Subtraction, multiplication and division
Subtraction borrows decimal 16 from the next column. In F213 − EC11, the column 2 − C needs a borrow: 16 + 2 − 12 = 6. The result is 0602, usually written 602. For fractions, line up the points before subtracting.
Multiplication uses partial products. FF × F = EF1, so FF × FF = EF1 + EF10 = FE01, equivalent to decimal 65,025. Division uses the usual quotient-and-remainder relationship: FFFF ÷ 7 gives quotient 2492 and remainder 1. Continued past the point, it is 2492.249249…, with 249 repeating.
Bitwise AND, OR and XOR
Bitwise operations compare whole numbers one bit at a time. AND returns 1 when both input bits are 1. OR returns 1 when either input bit is 1, including when both are 1. XOR returns 1 only when the bits differ. These operations do not accept fractional operands.
| Operation | Binary result | Hex result | Decimal |
|---|---|---|---|
| A5 AND 3C | 0010 0100 | 24 | 36 |
| A5 OR 3C | 1011 1101 | BD | 189 |
| A5 XOR 3C | 1001 1001 | 99 | 153 |
Word sizes and two's complement
A fixed-width word keeps only its selected number of bits. Integer addition, subtraction and multiplication wrap modulo 2 raised to that width. The stored bits can then be read as either an unsigned number or a signed two's-complement number.
The first line keeps the low w bits of an integer result. The second interprets that stored word as signed two's complement.
For example, decimal −28 becomes E4 in eight bits: 256 − 28 = 228. E4 therefore means unsigned 228 or signed −28. The equivalent binary procedure is to invert the positive number's bits and add one.
| Bits | Hex digits | Largest unsigned hex value |
|---|---|---|
| 8 | 2 | FF |
| 16 | 4 | FFFF |
| 32 | 8 | FFFFFFFF |
| 64 | 16 | FFFFFFFFFFFFFFFF |
Carry and signed overflow are different. In eight bits, FF + 01 stores 00 with a carry of 1. Read as signed numbers, that is −1 + 1 = 0, without overflow. But 7F + 01 stores 80: unsigned 128 fits, while signed 127 + 1 exceeds the signed range of −128 through 127.
Frequently asked questions
What is FF in decimal?
As an unsigned value, FF is 15 × 16 + 15 = 255. In an eight-bit signed two's-complement interpretation, the same bit pattern means −1.
What does 0x mean, and does letter case matter?
The prefix 0x identifies a hexadecimal number, so 0x10 means decimal 16. Uppercase and lowercase hex letters have the same value: FF and ff both mean unsigned 255.
Can hexadecimal numbers have a point?
Yes: hex 0.8 is decimal 0.5, and hex 0.4 is decimal 0.25. Use Any word size for fractional arithmetic; fixed-width words and bitwise operations use integers.
Why does hexadecimal division sometimes repeat?
A reduced fraction terminates in base 16 only when its denominator is a power of two, including 1. Otherwise its digits repeat; for example, 1 ÷ 3 is hex 0.5555… .
How do I convert hex to decimal in Excel?
Use =HEX2DEC("A5") to get 165. Excel accepts up to 10 hex digits and uses a 40-bit signed interpretation, so =HEX2DEC("FFFFFFFF5B") returns −165.
Can I divide a hex number by zero?
No, division by zero is undefined in hexadecimal, just as it is in decimal. Choose a nonzero divisor before interpreting the result.
Sources
- 1RFC 4648, section 8: Base 16 Encoding · RFC Editor · Accessed November 2026
- 2CS 3410: Number representations and arithmetic · Cornell University · Accessed November 2026
- 3Two's Complement · Cornell University · Accessed November 2026
- 4Built-in Types: Bitwise Operations on Integer Types · Python Software Foundation · Accessed November 2026
- 5HEX2DEC function · Microsoft · Accessed November 2026