Hex Calculator
Add, subtract, multiply, or divide hexadecimal numbers, with results shown in hex, decimal, and binary.
How It's Calculated
Formula
\text{result} = \text{hex}_A \;\text{op}\; \text{hex}_BHexadecimal is base-16: each digit represents a value from 0 to 15, using the digits 0-9 followed by a-f for 10-15. This calculator converts both hex inputs to decimal, applies the chosen arithmetic operation, and converts the result back to hexadecimal (and binary, for convenience). Hex digits are accepted in either uppercase or lowercase. Each input must be non-empty and contain only valid hex characters, and is limited to 13 digits to stay within JavaScript's exact-integer range (13 hex digits = 52 bits). Subtraction that produces a negative result is shown with a leading minus sign, and division uses integer (truncating) division with a zero divisor rejected.
Worked Examples
Adding two hex numbers: 1A + 0F
- 1A in decimal = 26
- 0F in decimal = 15
- 26 + 15 = 41
- 41 in hex = 29
Subtracting hex numbers: FF - 0A
- FF in decimal = 255
- 0A in decimal = 10
- 255 - 10 = 245
- 245 in hex = f5
Frequently Asked Questions
Why is hexadecimal used in computing?
Hexadecimal maps cleanly onto binary because each hex digit represents exactly 4 binary bits. This makes hex a compact, human-readable way to write binary values like memory addresses, color codes, and byte data without long strings of 0s and 1s.
Does it matter if I use uppercase or lowercase letters?
No. Both 'A' and 'a' represent the same value (10) in hexadecimal, and this calculator accepts either case for the a-f digits.
What happens if I divide by hex 0?
Division by zero is undefined, so this calculator rejects a divisor of 0 rather than returning an invalid result.
Why is there a 13-digit limit?
Results are kept within JavaScript's exact safe-integer range (up to 2^53 - 1). Since each hex digit represents 4 bits, 13 hex digits (52 bits) is the largest input width that guarantees results stay exactly representable.