Hexadecimal (base 16) writes numbers with sixteen symbols: the digits 0–9 followed by the letters A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15. Programmers use it everywhere — memory addresses, colour codes such as #FF8800, Unicode code points, checksums and machine registers — because each hex digit stands for exactly four bits. Two hex digits make one byte, so 0xFF is 255 and 0xFFFF is 65,535.
This hexadecimal calculator performs addition, subtraction, multiplication and division (whole quotient plus remainder) on two hex numbers, as well as the bitwise operations AND, OR and XOR that are so common in low-level code. It uses exact big-integer arithmetic, so numbers up to 64 hex digits (256 bits) are handled without rounding — far beyond what a typical pocket calculator or spreadsheet can do.
Every result is shown in hexadecimal, decimal and binary at once. Additions and subtractions come with a column-by-column table of carries and borrows, multiplications with their partial products, and divisions with the check . The optional converter row turns any decimal integer into hex and binary, which is handy when you need to cross-check a value from documentation or a debugger. To work purely with base 2, see the binary calculator.
How to use this calculator
- Type the first hexadecimal number A, for example 1A3F. Upper or lower case both work; a 0x prefix, spaces and underscores are ignored.
- Choose the operation: +, −, ×, ÷, AND, OR or XOR.
- Type the second number B, for example B7.
- Read the result in hex at the top, then in decimal and binary. Open the steps and the table to follow every carry, borrow or partial product.
- Optionally, type a decimal number in the converter field to see its hexadecimal and binary form.
The formula
A hexadecimal numeral stands for
Addition works column by column from the right: the result digit is and the carry is , which is 0 or 1.
Subtraction borrows 16 from the next column whenever .
Multiplication adds one shifted partial product per digit of : , and a shift by one hex place multiplies by 16.
Division finds the quotient and remainder with and .
Bitwise operations compare the binary expansions bit by bit: AND gives 1 only where both bits are 1, OR where at least one is 1, XOR where exactly one is 1. Because , each hex digit maps to a group of four bits, for example and .
Worked example
Take and .
Addition. From the right: , write 6 carry 1; , write F; , write A; then 1. The carries read 0001 and the sum is 1AF6 (6,902 in decimal).
Subtraction. = 1988 (6,536); the second column needs a borrow because 3 is smaller than B. Reversing the order gives −1988, the same magnitude with a minus sign.
Multiplication. = 12C309 (1,229,577).
Division. gives quotient 24 and remainder 83, that is 36 remainder 131 in decimal.
Bitwise. 1A3F AND B7 = 37, 1A3F OR B7 = 1ABF, 1A3F XOR B7 = 1A88.
Hex digits, bits and bytes
The table below is the key to doing hexadecimal arithmetic in your head. Each hex digit corresponds to one four-bit pattern (a nibble), so converting between hex and binary never needs any arithmetic — just replace each digit by its four bits.
| Hex | Decimal | Binary | Hex | Decimal | Binary |
|---|---|---|---|---|---|
| 0 | 0 | 0000 | 8 | 8 | 1000 |
| 1 | 1 | 0001 | 9 | 9 | 1001 |
| 2 | 2 | 0010 | A | 10 | 1010 |
| 3 | 3 | 0011 | B | 11 | 1011 |
| 4 | 4 | 0100 | C | 12 | 1100 |
| 5 | 5 | 0101 | D | 13 | 1101 |
| 6 | 6 | 0110 | E | 14 | 1110 |
| 7 | 7 | 0111 | F | 15 | 1111 |
For conversions between any bases (2 to 36, including octal) use the number base converter.
Where AND, OR and XOR are used
Bitwise operations are the everyday tools of systems programming. AND with a mask keeps selected bits: colour AND FF extracts the blue byte of a 24-bit RGB colour, and x AND F returns the last hex digit. OR sets bits, for example to switch on a flag in a status register. XOR flips bits; applying the same XOR twice restores the original value, which is why it appears in checksums, simple ciphers and parity calculations.
Negative numbers are usually stored in two’s complement, and the result of a bitwise operation on them depends on the register width. To keep results unambiguous, this calculator applies AND, OR and XOR to non-negative values only; the four arithmetic operations accept negative numbers written with a minus sign.
Frequently asked questions
How do you add hexadecimal numbers?
Line the numbers up on the right and add each column in decimal. If the column total is 16 or more, write the total minus 16 as a hex digit and carry 1. For example F + 7 = 22, which is 16 + 6: write 6 and carry 1. 1A3F + B7 = 1AF6.
What do the letters A to F mean in hexadecimal?
They are single digits for the values ten to fifteen: A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15. Base 16 needs sixteen distinct symbols, and the letters fill the gap after 9.
How do I convert a decimal number to hex?
Divide by 16 repeatedly and write the remainders from last to first. 255 ÷ 16 = 15 remainder 15, and 15 ÷ 16 = 0 remainder 15, so 255 = FF. The converter field of this calculator does it instantly for integers of any size.
How does hexadecimal division handle the remainder?
The calculator returns a whole-number quotient and a remainder such that A = B × Q + R. For 1A3F ÷ B7 the quotient is 24 and the remainder 83 (6719 = 183 × 36 + 131 in decimal). Division by zero is reported as an error.
What is XOR in hex?
XOR (exclusive or) compares the two numbers bit by bit and gives 1 where the bits differ. Convert each hex digit to four bits, XOR them, and convert back: B XOR 7 = 1011 XOR 0111 = 1100 = C.
Sources
- Knuth, D. E., The Art of Computer Programming, vol. 2: Seminumerical Algorithms, 3rd ed. — §4.1 Positional number systems, §4.3.1 classical algorithms
- Weisstein, E. W., Hexadecimal — Wolfram MathWorld
- Weisstein, E. W., XOR — Wolfram MathWorld
Last updated: