Sumivo · Mathematics
Hex Calculator
Add, subtract, multiply and divide two hexadecimal numbers, with every result shown in both hex and decimal. Exact arithmetic on whole hex numbers.
01 / inputs
02 / result
A + B (HEX)
C4
- A (decimal)
- 165
- B (decimal)
- 31
- Sum (A + B)
- C4₁₆ = 196
- Difference (A − B)
- 86₁₆ = 134
- Product (A × B)
- 13FB₁₆ = 5115
- Quotient (A ÷ B)
- 5₁₆ r A₁₆ = 5 r 10
Calculation trace
- A5₁₆ = 165₁₀Operand A to decimal
- 1F₁₆ = 31₁₀Operand B to decimal
- 165 + 31 = 196 = C4₁₆Add
- 165 − 31 = 134 = 86₁₆Subtract
- 165 × 31 = 5115 = 13FB₁₆Multiply
- 165 ÷ 31 = 5 remainder 10 = 5₁₆ r A₁₆Divide (integer)
Maintained by Jack Shi
How it works
Each hexadecimal digit is a power of sixteen, so A5 in base 16 is 10×16 + 5×1 = 165 in base 10 (the digits A–F stand for 10–15). The tool reads both operands that way, does the arithmetic on the whole numbers, and converts the answer back to hexadecimal. Addition, subtraction, and multiplication follow the ordinary rules on the decimal values; division is integer division, giving a whole-number quotient and a separate remainder (for example A5 ÷ 1F is 165 ÷ 31 = 5 remainder 10, shown as quotient 5 and remainder A). All of this runs on exact big integers, so results stay precise no matter how large the numbers get, unlike ordinary floating-point which loses precision past 2^53.
Assumptions & limits
- Operands must contain only the hex digits 0–9 and A–F (case-insensitive; an optional 0x prefix and leading zeros are allowed); anything else is rejected.
- Division is integer division: it returns a quotient and a remainder, not a hex fraction.
- A − B can be negative; it is shown with a minus sign rather than a two’s-complement pattern, because two’s complement needs a fixed bit width that a plain calculator does not assume.
- Inputs are capped at 32 hex digits each (128 bits) to keep the page responsive.
Verified runs
Synthetic examples executed at build revision be2e0e4 on . Cards round decimal results to 6 significant figures; matching uses full precision and the tolerance below. Matches cover the displayed fields, not every possible input or clinical or engineering validation.
Inputs: First operand: A5 hex integer; Second operand: 1F hex integer
Result: Hexadecimal sum: C4 (expected Hexadecimal sum: C4) ✓
Inputs: First operand: FF hex integer; Second operand: 1 hex integer
Result: Hexadecimal sum: 100 (expected Hexadecimal sum: 100) ✓
Inputs: First operand: 0x0ff hex integer; Second operand: a hex integer
Result: Hexadecimal sum: 109 (expected Hexadecimal sum: 109) ✓
How these runs were checked
Method: hex@1.0.0. Expectations come from the listed test fixtures or hand arithmetic; they are not copied from these executions. Omitted optional inputs use the method defaults. Run dates record execution, not expert review or fresh measurements.
Download all verified runs (JSON) — full inputs, returned values, expectations, timestamps and buildRevision.
- normal: . Absolute tolerance: 1e-10. Text and booleans match exactly. Full-precision result: Hexadecimal sum: C4. Expected: Hexadecimal sum: C4. Expectation: packages/calculator-core/tests/hex.test.ts
- boundary: . Absolute tolerance: 1e-10. Text and booleans match exactly. Full-precision result: Hexadecimal sum: 100. Expected: Hexadecimal sum: 100. Expectation: packages/calculator-core/tests/hex.test.ts
- sensitivity: . Absolute tolerance: 1e-10. Text and booleans match exactly. Full-precision result: Hexadecimal sum: 109. Expected: Hexadecimal sum: 109. Expectation: packages/calculator-core/tests/hex.test.ts
Reproduce from the source checkout with pnpm --filter @sumivo/web gen:verified-runs. A rebuild changes execution times; the revision identifies its Git starting point, including any uncommitted changes made for that build.
FAQ
- How do I add two hexadecimal numbers?
- Enter both numbers in hex and read the Sum row. For example A5 + 1F = C4, which is 165 + 31 = 196 in decimal. The tool shows every result in both hexadecimal and decimal.
- How does hex division work here?
- It is integer division. A5 ÷ 1F is 165 ÷ 31 = 5 with remainder 10, shown as quotient 5 and remainder A in hex. It does not produce a hexadecimal fraction.
- Can I enter lowercase letters or a 0x prefix?
- Yes. Lowercase a–f and an optional 0x prefix are accepted, and leading zeros are ignored, so 0x0ff and FF are read as the same value. Results are displayed with uppercase A–F.
- Is the result exact for very large hexadecimal numbers?
- Yes. The arithmetic uses arbitrary-precision integers, so a 64-bit or 128-bit operand is computed exactly — no rounding of the kind ordinary floating-point introduces beyond 2^53.
Related calculators
SOURCES
- OpenStax, Rice UniversityContemporary Mathematics — 4.3 Converting with Base Systems ↗
Base-16 positional notation and converting between base systems
Accessed 2026-09-22