Hex Calculator
Type two numbers and choose add, subtract, multiply, divide or power. The numbers can be hex, decimal, binary or octal, and the answer is shown in all four, with a remainder for a division. Pick 8, 16, 32 or 64 bits to see the two's complement, the bit pattern a register of that size would hold, and whether the result fits. The numbers can be any size, up to 500 digits. Everything runs in your browser.
Type the numbers in hex, or start one with 0x, 0b or 0o to use another base. A sign, spaces and underscores are allowed.
FF + 1A = 119
The size of the result needs 2 bytes.
The arithmetic is exact for whole numbers of any size, up to 500 digits per number. A division gives the quotient and the remainder, with the quotient cut toward zero and the remainder taking the sign of the first number. A power needs a whole exponent from 0 to 10000, and a result larger than 8000 bits is refused. With a width chosen, the two's complement shows the result as the bit pattern a register of that size would hold, and tells you whether it fits as a signed or an unsigned number. In hex mode 0b is read as the digits 0 and b, because b is a hex digit. Everything runs in your browser and nothing you type is uploaded.
Related Tools
[6 suggestions]Hex to ASCII Converter: Decode Hex Bytes to Text and Back
Convert hex to ASCII text and ASCII back to hex, with a byte table showing decimal, binary and control code names, and clear errors for bad digits or bytes above 7F.
Format ConversionNumber Base Converter
Convert whole numbers between binary, octal, decimal, hex and any base from 2 to 36, with two's complement.
Developer & WebBitwise Calculator
Apply AND, OR, XOR, NOT, shifts and rotations to 8, 16, 32 or 64-bit numbers and see the result in binary, hexadecimal and signed and unsigned decimal.
Developer & WebText to Hex Converter
Convert text to hexadecimal bytes and hex back to text, in UTF-8, UTF-16 or Latin-1, with your choice of separator and prefix.
Format ConversionIP Address Converter
Convert IPv4 and IPv6 addresses between notations: whole number, hex, binary, expanded and compressed IPv6, with reverse DNS names and the address type.
Developer & WebIEEE 754 Float Converter
See the sign, exponent and fraction bits of a 32 bit or 64 bit float, the exact value it stores, and the shortest decimal that reads back the same.
Developer & WebAbout the Hex Calculator
Hexadecimal uses sixteen digits, 0 to 9 and A to F, where A is 10 and F is 15, so adding in hex follows the same carrying rule as decimal but carries at 16: A plus B is 21 in decimal, which is 15 in hex, and FF plus 1 is 100. This calculator does the arithmetic exactly with whole numbers of any size, so a long hash or a 64-bit address is not rounded. Choose the base the numbers are written in, or start a number with 0x, 0b or 0o to use another base for that number alone, and note that in hex mode 0b is read as the digits 0 and b because b is a hex digit. Spaces and underscores between digits are allowed, so FF_FF and 1111 0000 both work, and a leading minus sign gives a negative number. Subtraction can go below zero, and the result is shown with a minus sign. Division gives a whole quotient cut toward zero and a remainder with the sign of the first number: 100 hex divided by 7 is 24 hex with a remainder of 4. A power needs a whole exponent from 0 to 10000. With a width chosen, the two's complement shows the result as the bit pattern a register of that size holds: minus 1 in 8 bits is FF, minus 128 is 80, and 256 wraps to 00, and the tool says whether the value fits as a signed or an unsigned number. The size of the result in bytes is shown too. Everything runs in your browser and nothing you type is uploaded.
How do you add hex numbers?▾
Add the digits column by column from the right, carrying when a column reaches 16. A is 10, B is 11 and F is 15, so A plus B is 21, which is 15 in hex: write 5 and carry 1. FF plus 1 is 100. The calculator does it for any size.
How do you subtract hex numbers?▾
Subtract column by column and borrow 16 when a digit is too small. 10 minus 1 in hex is F. If the second number is larger, the answer is negative and is shown with a minus sign, and with a width chosen you also see its two's complement.
What is the two's complement of a hex result?▾
It is how a computer stores a negative number in a register of fixed size. Minus 1 in 8 bits is FF, and minus 128 is 80. Choose 8, 16, 32 or 64 bits and the calculator shows the pattern and whether the value fits as signed or unsigned.
Can I mix hex and decimal numbers?▾
Yes. Start a number with 0x for hex, 0b for binary or 0o for octal, and it is read in that base whatever you chose for the others. The answer is always shown in hex, decimal, binary and octal.
How does division work with a remainder?▾
The quotient is cut toward zero and the remainder takes the sign of the first number, so that quotient times divisor plus remainder gives the first number back. 100 hex divided by 7 is 24 hex with a remainder of 4.
Is there a limit on the size of the numbers?▾
Each number can have up to 500 digits, and results are limited to 8000 bits. Within that the arithmetic is exact, so very long values are not rounded.