Hex Calculator
Arithmetic on two hexadecimal numbers.
What it does
Hexadecimal is a base 16 number system that uses the digits 0 through 9 followed by A through F. Each hex digit represents four binary digits, which makes it convenient for memory addresses, colour codes and machine level data.
University of Maryland notes on number bases show that a hex number is a sum of digits times powers of 16, and give examples such as 4EA in base 16 equal to 1258 in decimal.
Stanford University handouts describe hexadecimal as a compact representation of binary used for memory addresses, network addresses and HTML colours.
This tool accepts two hex strings, converts them to integers, applies the chosen operation and reports the result in both hex and decimal.
Division is integer division, matching common programming behaviour for whole number operands.
How to use
- Enter the first hexadecimal value using 0 to 9 and A to F.
- Enter the second hexadecimal value in the same form.
- Choose an operation.
- Read the result in hexadecimal in the main area.
- Check the decimal result and both decimal operands.
- Try 1F and 2A with addition to reproduce the example.
Formula
- 16
- The base of the hexadecimal system.
- A to F
- Digit symbols for the values 10 through 15.
- d(i)
- The digit at position i.
- XOR
- Bitwise exclusive or on the two integers.
The engine parses each input with base 16 and rejects strings containing characters outside 0 to 9 and A to F. Results are printed in uppercase hex without a prefix.
Worked example
Example: adding two hex values
First value 1F and second value 2A.
- 1F in hex is 1 x 16 + 15 = 31 in decimal.
- 2A in hex is 2 x 16 + 10 = 42 in decimal.
- Adding gives 73 in decimal.
- 73 in decimal is 4 x 16 + 9, which is 49 in hex.
- The tool reports hex 49 and decimal 73.
- The XOR of the same operands is 35 in hex, or 53 in decimal.
Reference table
| Operation | Hex result | Decimal result |
|---|---|---|
| Add | 49 | 73 |
| Subtract | -B | -11 |
| Multiply | 522 | 1302 |
| XOR | 35 | 53 |
Limits
- Inputs are limited to 16 hex digits.
- Division truncates to an integer.
- The tool does not handle a 0x prefix or spaces.
- Subtraction of a larger value from a smaller one is rejected by the parser only if out of range.
Common mistakes
- Including a 0x prefix in the input fields.
- Using lowercase letters, which the tool accepts but prints uppercase.
- Expecting floating point results from division.
- Confusing hex F with the letter used for fifteen.
- Entering digits beyond 16 characters, which the tool rejects.
Try it yourself
Quick checks. Answers sit tucked under each question.
What is 1F plus 2A in hex?
49, which is 73 in decimal.
What does hex A represent?
The value 10.
Why is hex useful in computing?
Each hex digit corresponds to four binary digits.
Questions
What is hexadecimal?
A base 16 number system using digits 0 to 9 and A to F.
Why is it used?
It compactly represents binary data.
Does the tool add a 0x prefix?
No. Results are printed as plain uppercase hex.
How does division work?
It returns the integer quotient, discarding any remainder.
Can I enter lowercase letters?
Yes, they are converted to uppercase.
What is XOR?
A bitwise operation that sets a bit when exactly one input bit is set.