Hex Calculator: Free Online Hex Math Tool

Hex Calculator

Enter two hexadecimal values and select an operation to calculate the result in hex, decimal, binary and octal.

0x
0x
Decimal A
-
Decimal B
-

This hex calculator lets you add, subtract, multiply, divide and run bitwise operations on two hexadecimal numbers. It is made for programmers, students and web developers who need a fast answer. Every result appears in hex, decimal, binary and octal at the same time, and you do not need to sign in.

What Is Hexadecimal and How Do You Calculate It?

Hexadecimal is a base-16 number system that uses the digits 0 to 9 and the letters A to F, where A is 10 and F is 15. Each position in a hex number is worth a power of 16, just as each position in a decimal number is worth a power of 10.

To convert a hex number to decimal by hand, multiply each digit by its place value and add the results. For 1A2F, the calculation is 1 × 4096 + 10 × 256 + 2 × 16 + 15 = 6703. The same number written in decimal is 6703.

Programmers like hex because one hex digit equals exactly four binary digits, so one byte is always two hex digits. FF is 255, the largest value a byte can hold. That is why you see hex in memory addresses, file signatures, network masks, error codes and web color codes such as #FF8800. The prefix 0x marks a number as hex in many programming languages, and the calculator shows it beside each input so you only type the digits.

How to Use the Hex Calculator

You can finish a calculation in four short steps: enter value A, pick an operation, enter value B and read the results.

  1. Type your first number in Hex Value A. The placeholder shows 1A2F as a sample. Leave out the 0x prefix, because it is already displayed next to the field.
  2. Open the Operation menu and choose one. The Arithmetic group has + Add, − Subtract, × Multiply, ÷ Divide, % Modulo and ^ Power. The Bitwise group has AND, OR, XOR, << Shift Left and >> Shift Right.
  3. Type your second number in Hex Value B, for example FF.
  4. Check the Decimal A and Decimal B lines under the inputs to confirm that both values were read the way you meant.
  5. Press Calculate. The Calculation Results panel shows the expression in hex and in decimal, followed by the answer in Hexadecimal, Decimal, Binary and Octal. Results also refresh as you edit a value or change the operation.
  6. Use the copy icon next to any line to copy that one format, or press Copy All to take all four. Swap exchanges the two inputs, and Reset clears the form. Earlier results are listed under Recent Calculations.

You can type lowercase letters, because the fields convert them to uppercase. Any character that is not 0 to 9 or A to F is removed as you type, so a stray space or a pasted 0x prefix will not break the calculation.

Worked Example: Adding 1A2F and FF

Adding 1A2F and FF gives 1B2E in hex, which is 6958 in decimal. Here is what you see and why it is correct.

  • Input: Hex Value A = 1A2F, Operation = + Add, Hex Value B = FF.
  • Decimal check: 1A2F is 6703 and FF is 255, so the sum is 6703 + 255 = 6958.
  • Hexadecimal: 1B2E. A quick mental check: FF is one less than 100, so adding it to 1A2F gives 1B2F minus 1, which is 1B2E.
  • Binary: 1101100101110.
  • Octal: 15456.

Now try the same inputs with XOR. 1A2F XOR FF flips the lowest eight bits of A, so the result is 1AD0 (6864 in decimal). The top byte, 1A, is untouched because B has zeros there. That is the pattern behind many masking and toggling tasks.

How Do You Read the Results?

Each result line answers a different question, so choose the one that matches your task. Hexadecimal is the answer in the same notation you typed. Decimal is the everyday number, useful for sanity checks. Binary shows the individual bits, and octal is handy for Unix file permissions and older systems.

What each operation does

OperationExampleResult
AddFF + 01100
ANDFF AND 0FF
Shift Left1 << 410

AND keeps only the bits that are set in both values, which is how you isolate a field or apply a mask. OR sets a bit if it is set in either value. XOR sets a bit only when the two values differ. Shift Left by n moves the bits n places up, which doubles the value for each step. Shift Right moves them down, which halves the value for each step and drops any remainder.

Special cases to expect

  • Division is whole-number division. 1F divided by 2 shows F (15), not 15.5, because the fraction is dropped. Use Modulo to get the remainder, which is 1 in this case.
  • Negative results get a minus sign. Subtracting 8 from 5 shows -3 in hex and decimal. The binary line then shows the 32-bit two's complement form, which is 30 ones followed by 01 (11111111111111111111111111111101).
  • Power grows fast. 10 ^ 2 is 16 squared, so the answer is 100 in hex and 256 in decimal.
  • Divide and Modulo by zero show an error message instead of a result. Change Hex Value B to a nonzero number.

Who Uses a Hex Calculator?

A hexadecimal calculator saves time whenever you work with values that are written in base 16 but need arithmetic or bit logic.

  • Programmers and embedded developers add offsets to memory addresses, build bit masks, and check what a register value looks like after a shift.
  • Web designers and front-end developers work out color channels. The color #1A2F3C has three channels: 1A, 2F and 3C. Adding 20 to a channel brightens it, and you can read its decimal value from the Decimal A or Decimal B line.
  • Computer science students verify homework on number systems and two's complement without redoing long conversions on paper.
  • Network and security learners apply masks with AND and flip flags with XOR when reading packet fields or checksums.
  • Anyone converting a single value can enter the number as Hex Value A, enter 0 as Hex Value B and choose Add. The result lines then show that number in all four formats.

If you want to practice the same operations in base 2, the binary calculator works the same way, and the binary translator turns binary into readable text.

Best Practices and Troubleshooting

Most surprising results come from one of a few input habits, and each has a quick fix.

  • Type digits only. Enter 1A2F, not 0x1A2F or #1A2F. The calculator removes anything that is not a hex digit, so a pasted prefix can silently change your number. The letter O is not a digit, and neither are the other letters beyond F. Watch for 0 versus O.
  • Check Decimal A and Decimal B first. If the decimal preview is not what you expect, the input is wrong, not the operation.
  • Both fields are required. If you see a message asking for both values, fill the empty field. For a one-number conversion, use 0 as the second value.
  • Match the operation to the goal. Use AND to keep bits, OR to set bits and XOR to toggle bits. People often pick OR when they want XOR.
  • Keep leading zeros in mind. The result is shown without padding, so 000F appears as F. Add the zeros yourself if your format needs a fixed width, such as two digits per byte.
  • Verify one value by hand. For important work, convert the result to decimal and compare it with a quick manual calculation, as in the worked example above.

Limitations to Know About

The calculator is designed for everyday programming and learning tasks, and a few limits apply to very large numbers. Values with more than about 13 hex digits can lose precision, especially after multiplication or a large power. Bitwise operations and shifts work on 32-bit numbers, so a result above FFFFFFFF will not be reliable. The binary line also shows only the low 32 bits for large or negative results.

The tool accepts hexadecimal input only, so it will not turn a decimal number into hex on its own. It also does not handle fractions or hex digits after a point. For long hashes or cryptographic work, use a dedicated big-number library instead.

Enter your two values above, choose an operation and press Calculate to see the answer in four number systems. For more utilities like this one, browse the full online calculators and utilities collection.

Frequently Asked Questions

How do you calculate hexadecimal numbers?
Enter two hex values, choose an operation and press Calculate. The Hex Calculator returns the answer in hex, decimal, binary and octal. For example, 1A2F plus FF gives 1B2E in hex, which is 6958 in decimal.
How do I convert hex to decimal with this calculator?
Type your hex number as Hex Value A, enter 0 as Hex Value B and choose Add. The Decimal line shows the converted value. For example, 1A2F shows 6703. Decimal A also previews the value as you type.
What operations does the hex calculator support?
The Hex Calculator supports Add, Subtract, Multiply, Divide, Modulo and Power, plus the bitwise operations AND, OR, XOR, Shift Left and Shift Right. Divide returns a whole number, so 1F divided by 2 shows F, and Modulo gives the remainder.
Can I type lowercase letters or a 0x prefix in the hex calculator?
You can type lowercase letters, and the calculator converts them to uppercase. Do not type 0x, because the field already shows it. Any character outside 0 to 9 and A to F is removed as you type.
Why does my hex calculator result show a minus sign or a long binary number?
A minus sign means the answer is below zero, such as 5 minus 8 giving -3. The binary line then shows a 32-bit two's complement form, which looks long. Results above FFFFFFFF show only the low 32 bits in binary.
Is the hex calculator free, and does it need a sign-in?
Yes, the Hex Calculator is free and needs no sign-in. Enter your values, press Calculate and use the copy icons or Copy All to save the hex, decimal, binary and octal results for your code or notes.
Recommended

Explore VPN options

A VPN changes your network exit. It does not guarantee anonymity.

Hide Your IP Encryption Network coverage
Protect My IP Now