Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

Free tool · Developer tools

Hex calculator

Type two hex numbers and pick an operation. 1A3F plus 0B2C is 256B, which is 6,719 + 2,860 = 9,579 in decimal. The answer comes with the working, the decimal and binary values and all four operations side by side.

  • Free
  • No sign-up
  • Runs in your browser

By Maaz Zindani · Updated

Digits 0 to 9 and A to F, in either case. A leading minus, 0x, spaces and low lines (_) are fine.
1A3F + B2C

256B9,579 in decimal

  • 6,719 + 2,860
  • 0x256B
  • 4 hex digits
Decimal
9,579
Binary
10010101101011
Hex digits
4
Bytes needed
2
Working
column 1: F + C = 27, write B, carry 1
column 2: 3 + 2 + 1 = 6, write 6
column 3: A + B = 21, write 5, carry 1
column 4: 1 + 0 + 1 = 2, write 2
result = 256B
All four operations on A and B
OperationHexDecimal
Add (A + B)256B9,579
Subtract (A - B)F133,859
Multiply (A × B)12537D419,216,340
Divide (A ÷ B)2 remainder 3E72 remainder 999

How to use the Hex Calculator

  1. Type Hex number A and Hex number B with the digits 0 to 9 and A to F.
  2. Pick add, subtract, multiply or divide in the Operation menu.
  3. Read the hex answer, then the decimal and binary values and the line by line working under it.
  4. Swap A and B reverses a subtraction, and Copy the result puts the hex digits on your clipboard.

How do you add hex numbers?

Hex addition follows the school method, with one change: a column carries when it reaches 16 instead of 10. Digits above 9 are letters, so A is 10, B is 11, C is 12, D is 13, E is 14 and F is 15. Add 1A3F and 0B2C from the right. Column one: F + C = 27, write B, carry 1. Column two: 3 + 2 + 1 = 6, write 6. Column three: A + B = 21, write 5, carry 1. Column four: 1 + 0 + 1 = 2, write 2. The answer is 256B.

A total of 27 becomes B with a carry because 27 is one 16 plus 11. The page prints the same column lines under every answer for addition, so you can compare them with your own sheet. Check the sum in decimal: 6,719 + 2,860 = 9,579, and 256B read back is 2 × 4096 + 5 × 256 + 6 × 16 + 11 = 9,579.

A common case is a number made only of F digits. FFFF plus 1 is 10000, the same jump as 9999 plus 1 in decimal. Every F column becomes 0 and a new leading 1 appears.

All four operations on 1A3F and 0B2C
OperationHexDecimal
Add (A + B)256B9,579
Subtract (A - B)F133,859
Multiply (A × B)12537D419,216,340
Divide (A ÷ B)2 remainder 3E72 remainder 999

How do you subtract, multiply and divide hex numbers?

Subtraction borrows 16. Take 3F minus 1A. In the first column, F - A gives 5, write 5, because F is 15 and A is 10. In the second column, 3 - 1 gives 2, write 2. The answer is 25, which is 63 minus 26 = 37 in decimal. When A is smaller than B the answer is negative: 1A minus 3F is -25, and the working shows B minus A with the sign flipped.

Multiplication gives a product with about as many digits as both numbers together. FF times FF is FE01, which is 255 × 255 = 65,025. For the example numbers the product is 12537D4, or 19,216,340. Nothing is rounded, so a product of two long numbers keeps every digit.

Hex division gives a whole-number quotient plus what is left over. 1A3F divided by 0B2C is 2 with remainder 3E7, and the page shows the check: 2 × B2C + 3E7 = 1A3F. The quotient is cut toward zero, so negative B divided by 4 gives -2 remainder -3, and the remainder takes the sign of the first number.

How do I turn the hex answer into decimal?

Each digit has a place value that is a power of 16. The last digit counts ones, the next one counts sixteens, then 256s, 4096s and so on. The table lists the first six. 1A3F = 1×4096 + 10×256 + 3×16 + 15×1 = 6719.

The decimal value of every answer is shown under the hex digits. The binary line works the other way: each hex digit is exactly four bits, so 256B is 0010 0101 0110 1011, which is 10010101101011 with the leading zeros dropped. That is why hex is popular for memory addresses and color codes, and why two hex digits fill one byte.

Place values of the first six hex digits
PowerDecimalHex
16^011
16^11610
16^2256100
16^34,0961000
16^465,53610000
16^51,048,576100000

How long can the hex numbers be?

Each number may have up to 256 digits, with an optional minus sign, an optional 0x prefix, and spaces or low lines between the digits. 0xDEAD_BEEF is read as DEADBEEF. Letters can be upper or lower case. The sums use whole numbers of any size, so 20 F digits plus 1 gives 1 followed by 20 zeros (21 digits) with no overflow and no rounding.

Step-by-step columns are drawn for sums and differences of up to 16 digits; longer inputs still get the answer, its decimal value and the table. If you need AND, OR or shifts, open the bitwise calculator, for plain base changes use the number base converter, and for the same sums in base 2 use the binary calculator.

Use it with

Questions

What is 7F plus 1 in hex?

It is 80. F plus 1 makes 16, so the last digit is 0 with a carry, and 7 plus the carry gives 8.

How do I add two hex numbers by hand?

Work from the rightmost column and pass a carry of 1 to the next column each time a total hits 16. For 1A3F + 0B2C the result is 256B.

Can the hex calculator handle negative numbers?

Yes. Start a number with a minus sign. For example 1A minus 3F gives -25. The result keeps a plain leading minus sign, with no two's complement form.

Do I type 0x before a hex number?

It is optional. 0xFF, 0XFF and FF are read as the same number, 255.

What happens when I divide by zero?

You get an error message instead of a result. Switch the operation and the table marks the divide row undefined.

Does anything I type leave this page?

No. The sums run in the page itself, and the two numbers are not sent anywhere.

The tool's results are computed in your browser by the code on this page; the explanations are checked against the tool's own output.