Hex Calculator
Do arithmetic and bitwise operations on hexadecimal numbers. Every result is shown in hex, decimal, binary and octal, so you can check memory offsets, color values, masks and checksums quickly.
Digits 0-9 and A-F; a 0x or # prefix is fine
How to use the Hex Calculator
- Enter hex number A, such as 1F4 or 0xDEADBEEF.
- Choose the operation: + − × ÷, mod, AND, OR, XOR, NOT or a shift.
- Enter number B or the shift amount in bits.
- Read the hex result with its decimal, binary and octal values.
- Copy the results for your code or notes.
Hexadecimal arithmetic
Hexadecimal (base 16) works like decimal, but each column is worth 16 times the one to its right. 1F4 = 1×256 + 15×16 + 4 = 500. When adding, carry 1 whenever a column reaches 16; when subtracting, borrow 16. Because 16 = 2⁴, every hex digit is exactly four bits, which makes bitwise operations easy to read in hex.
| Operation | Example (hex) | Decimal check |
|---|---|---|
| Addition | 1F4 + A7 = 29B | 500 + 167 = 667 |
| Subtraction | 1000 − 1 = FFF | 4096 − 1 = 4095 |
| Multiplication | FF × 10 = FF0 | 255 × 16 = 4080 |
| Division | 64 ÷ 7 = E remainder 2 | 100 ÷ 7 = 14 r 2 |
| AND | DEADBEEF AND FFFF = BEEF | Keeps the low 16 bits |
| XOR | FF00 XOR 0FF0 = F0F0 | 1 where bits differ |
| Shift left | 1 << 8 = 100 | 1 × 2⁸ = 256 |
Common hex values
| Hex | Decimal | Meaning |
|---|---|---|
| FF | 255 | Largest 1-byte value |
| 100 | 256 | Values in one byte |
| FFFF | 65,535 | Largest 16-bit unsigned value |
| 7FFFFFFF | 2,147,483,647 | Largest signed 32-bit integer |
| FFFFFFFF | 4,294,967,295 | Largest unsigned 32-bit integer |
| 400 | 1,024 | 1 KiB |
| 100000 | 1,048,576 | 1 MiB |
Frequently asked questions
How do you add hexadecimal numbers?
Add digit by digit from the right, as in decimal, but carry when a column reaches 16. For example 1F4 + A7: 4 + 7 = B, F + A = 25 = 19 hex (write 9, carry 1), 1 + 1 = 2, giving 29B (500 + 167 = 667).
What are the hex digits?
Hexadecimal is base 16 and uses 0-9 plus A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15. Each hex digit is exactly 4 bits, so two hex digits make one byte (00 to FF, or 0 to 255).
What is 0x in front of a number?
0x is a prefix used in programming languages such as C, JavaScript and Python to mark a number as hexadecimal. 0xFF means hex FF, which is 255 in decimal. The calculator accepts it, along with the # used for colors.
How do I use AND to mask a hex value?
AND keeps only the bits that are 1 in the mask. DEADBEEF AND FFFF keeps the lowest 16 bits and gives BEEF. AND with FF00 keeps the second-lowest byte.
How is hex subtraction done?
Subtract column by column, borrowing 16 instead of 10 when a digit is too small. 1000 − 1 = FFF in hex, just as 1000 − 1 = 999 in decimal.
Why do programmers use hexadecimal?
Because one hex digit maps to exactly 4 binary bits, hex is a compact and readable way to write binary data such as memory addresses, colors (#2F6B4F), byte values and bit masks.