Maths

Hex Calculator

Add, subtract, multiply, divide, AND, OR or XOR hexadecimal numbers exactly, with the answer in every base.

By Nitin Raturi · Last reviewed

Hexadecimal numbers

How to use the Hex Calculator

Add, subtract, multiply, divide or compare hexadecimal numbers, and see the answer in every base.

  1. Type the first hex number.
  2. Choose the operation.
  3. Type the second hex number.
  4. Read the answer in hex, decimal, octal and binary.

Good to know

  • Each hex digit is exactly four binary digits.
  • Results are exact at any length.

Whole numbers, exact to any size. Your numbers stay in this browser.

First hex number

A whole number in base 16, using 0–9 and A–F (A = 10 … F = 15).

How to fill it in

  • Type up to 32 digits, such as FF, 1a2b or 0xFF.
  • Upper or lower case; a minus sign is allowed.

Example

FF is 255 in decimal: 15 × 16 + 15.

Operation

What to do with the two numbers.

How to fill it in

  • Add, subtract, multiply, or divide (whole-number part and remainder).
  • AND, OR and XOR work bit by bit.

Example

FF × FF = FE01; DEAD XOR BEEF = 6042; 64 ÷ 7 = E remainder 2.

Second hex number

The other whole number, in base 16.

How to fill it in

  • Type 0–9 and A–F; for division it cannot be 0.

Example

FF + 1A = 119 (281 in decimal).

FF + 1A

119

In decimal: 281.

Binary
100011001
Octal
431
Decimal
281
Hexadecimal
119

Whole numbers only. Division keeps the whole-number part and shows the remainder. AND, OR and XOR work bit by bit on numbers of zero or more.

How this calculator works

  1. Step 1Place values…256 16 1Each place is worth sixteen times the one to its right.
  2. Step 2Digits0–9, A–FA is 10 and F is 15.
  3. Step 3Every baseExactThe answer is shown in hex, decimal, octal and binary.

Hexadecimal, or base 16, packs four binary digits into each hex digit, which is why programmers use it for colours, memory addresses and bytes. FF is 15 × 16 + 15 = 255.

Worked example: FF + 1A

Adding in base 16
Rule
a column total of 16 or more carries 1
  1. FF15 × 16 + 15255
  2. 1A1 × 16 + 1026
  3. Sum in hex119
  4. Sum in decimal255 + 26281

The same method, carrying when a column reaches the base, is how OpenStax adds in bases 6 and 12.

Arithmetic and bitwise operations

  • ArithmeticFF × FF = FE01Whole-number division too: 64 ÷ 7 = E r 2.
  • BitwiseDEAD XOR BEEF = 6042AND, OR and XOR compare the bits.

Read the result

The headline is the answer in hexadecimal; the table repeats it in binary, octal and decimal.

Assumptions and limits

  • Whole numbersNo hex fractions.
  • Any sizeExact up to 32 hex digits in each input.
  • Sign, not two’s complementNegative numbers use a minus sign.

Each hexadecimal digit stands for four binary digits, so the two convert directly.

For base-2 arithmetic, use the binary calculator. Web colours are written in hex; the color converter turns them into RGB, HSL and OKLCH.

Common mistakes

  • Mistake: Treating 10 in hex as ten.

    Instead: Hex 10 is sixteen; check the decimal line.

  • Mistake: Using G or higher letters.

    Instead: Hex digits stop at F, which is 15.

Checking the method

Every golden case is rechecked with Python’s own base-16 conversion.

An independent script reads numbers with Python’s int(text, 16) and writes results with its hexadecimal formatting.

Read how we test our calculators, or browse more maths calculators.

Frequently asked questions

How do I add hex numbers?

Add column by column and carry when a column reaches 16. FF + 1A = 119 (281).

What is FF in decimal?

FF is 15 × 16 + 15 = 255, the largest value of one byte.

What is FF × FF?

FF × FF = FE01 in hex, or 65,025 in decimal.

What does XOR do in hex?

It compares the bits of both numbers and keeps a 1 where they differ. DEAD XOR BEEF = 6042.

How does hex division work here?

It gives the whole-number quotient and the remainder: 64 ÷ 7 = E remainder 2.

Sources and methodology

The formulas are standard time-value-of-money results. We check every figure against golden values worked out independently, by closed form and by month-by-month simulation; see the methodology.

Written and maintained by Nitin Raturi, a software engineer (about the author). Last reviewed 3 Nov 2026; next review due by . Found an error? Tell us.

Changelog

  • : Initial release.