Hex Calculator

Result (hex)
119
Result (decimal)
281
Result (binary)
100011001
Check in decimal
255 + 26 = 281
Arbitrary precision

Do arithmetic directly in hexadecimal. Results are exact for any size and shown in hex, decimal and binary, with a decimal check line.

Hex arithmetic by hand

Addition works like decimal addition with a carry at 16 instead of 10. For FF + 1A: F + A = 15 + 10 = 25 = 16 + 9, so write 9 and carry 1; F + 1 + 1 = 17 = 16 + 1, write 1 and carry 1; the result is 119 (281 in decimal, which matches 255 + 26).

For subtraction, borrowing 1 from the next hex place gives you 16 in the current place. In 1000 − 1, the borrow passes through the two middle zeros, leaving FFF. The decimal check is 4096 − 1 = 4095.

Bitwise operations

AND, OR and XOR work bit by bit, which is where hex shines: each digit is four independent bits. DEADBEEF AND FFFF keeps only the low 16 bits, BEEF. That is the usual way to extract a field or truncate a value to a fixed width, for example AND FFFFFFFF to model a 32-bit register.

Results are exact at any size; nothing overflows. To see the bits of a result, use hex to binary; to interpret it as a negative number, the signed binary converter.

Related guides

FAQ

Frequently Asked Questions

What is FF + 1 in hex?
100. FF is 255, and 255 + 1 = 256 = 1 × 16², written 100 in hex.
How does hex division work here?
÷ performs integer division and drops the remainder; use mod to get the remainder. 64 ÷ 7 = E and 64 mod 7 = 2 in hex (in decimal, 100 ÷ 7 = 14 remainder 2).
Does it overflow at 32 or 64 bits?
No. Values are arbitrary-precision, so FFFFFFFF + 1 = 100000000. To model fixed-width overflow, mask the result with AND, for example AND FFFFFFFF.
Copied to clipboard!