Hex Subtraction Calculator

Enter two hexadecimal numbers to subtract the second from the first.

Result

4865
18,533
41,970
23,437

How it is calculated

Both entries are read as hexadecimal numbers (digits 0 to 9 and letters A to F, upper or lower case) and converted to ordinary numbers: A = Σ digit × 16position, and the same for B. The tool then computes A − B and shows it both as hex and as a decimal number, together with the two decimal values it started from. By hand you work column by column from the right, and when a digit is too small you borrow 1 from the next column, which adds 16 (not 10) to the current one. Enter plain digits only, with no 0x prefix or spaces. Leading zeros are ignored. The first number must be at least as large as the second: a negative difference gives no result. After leading zeros, each value may have at most 13 hex digits (below 252), so the decimal digits are always exact; longer values give no result instead of a rounded answer.

Worked example

Subtract 5B8D from A3F2. Right column: 2 is smaller than D (13), so borrow, 18 − 13 = 5. Next: F − 1 (borrowed) − 8 = 15 − 1 − 8 = 6. Next: 3 is smaller than B (11), so borrow, 19 − 11 = 8. Left column: A − 1 − 5 = 10 − 1 − 5 = 4. The difference is 4865 in hex. Check in decimal: 41,970 − 23,437 = 18,533, which is 4865 in hex.

Try this example →

Common mistakes

  • Typing a prefix such as 0x or # before the number: the tool accepts only the digits 0 to 9 and letters A to F, so these give no result.
  • Putting the numbers in the wrong order: the first box is the number you subtract from, and a smaller first number gives no result rather than a negative answer.
  • Borrowing 10 instead of 16 when subtracting by hand, which is the usual cause of a wrong answer when checking the tool.
  • Treating a hex string like 10 as ten: it is sixteen, so 10 − 1 is F (15), not 9.
  • Pasting a 64-bit address of 16 hex digits: values longer than 13 significant hex digits are refused, so split the address or subtract the low part by hand.

About this calculator

Hexadecimal subtraction works exactly like decimal subtraction, but each digit runs from 0 to F (15) instead of 0 to 9, so a borrow pulls a value of 16 from the next column rather than 10. Subtracting 1 from 10 in hex, for example, requires borrowing and produces F, since the column just below the borrowed 1 has 16 available rather than 10.

Hex shows up constantly in low-level programming — memory addresses, color codes, byte values, and CPU register contents are all conventionally written in hexadecimal because each hex digit maps cleanly onto exactly 4 binary bits, making it a compact stand-in for binary. Developers subtracting memory addresses to find a buffer size, working out an offset between two pointers, or debugging a hex dump by hand use a calculator like this to avoid manual borrowing errors, which are easy to make once letters A through F enter the mix.

Enter two hexadecimal numbers and the calculator subtracts the second from the first, showing the result in both hex and decimal.

Was this helpful?

You can pick up to 3 reactions.

Comments (0)

  • Be the first to comment.

Popular calculators

All Calculators