Skip to content

Hex Calculator

Hexadecimal arithmetic and conversion between hex, decimal, binary and octal, for numbers of any size.

MathUpdated Free · No sign-up

How to use the Hex Calculator

  1. Pick what you want to work out using the tabs: Hex arithmetic or Base conversion.
  2. Enter First number (hexadecimal).
  3. Choose Operation.
  4. Read your answer in the results panel. It updates as you type, and the breakdown, step-by-step working and any charts or tables appear below it.
  5. Use Share link to save or send the exact calculation, or Copy to paste the results elsewhere.

What hexadecimal is

Hexadecimal (hex) is base 16. It uses the digits 0–9 and then the letters A–F for ten to fifteen. Each place is worth 16 times the place to its right, so 2F = 2 × 16 + 15 = 47 and FF = 15 × 16 + 15 = 255.

value = Σ digitᵢ × 16ⁱ

Programmers like hex because one hex digit is exactly four binary bits. A byte (8 bits) is always two hex digits, which is why colours look like #1E90FF and memory addresses like 0x7FFE.

Converting between bases

  • Hex to decimal: multiply each digit by its power of 16 and add. 1A3F = 1 × 4096 + 10 × 256 + 3 × 16 + 15 = 6,719.
  • Decimal to hex: divide by 16 repeatedly and read the remainders backwards. 3054 ÷ 16 = 190 r 14 (E); 190 ÷ 16 = 11 r 14 (E); 11 ÷ 16 = 0 r 11 (B). So 3054 = BEE.
  • Hex to binary: replace each hex digit with its four-bit pattern. B2 → 1011 0010.
  • Octal (base 8) groups bits in threes instead of fours. Unix file permissions such as 755 are octal.

Hex arithmetic

Addition carries when a column reaches 16 rather than 10. For 1A3F + B2: F + 2 = 17, which is 1 carry 1; 3 + B + 1 = 15 = F; A stays A; 1 stays 1. The answer is 1AF1, or 6,897 in decimal. The calculator does the arithmetic with arbitrary-precision integers and shows the decimal equivalents at each step so you can check them.

Bitwise AND, OR and XOR work bit by bit, so they are handy for masks: 0xFF AND 0x3C keeps only the bits set in both, giving 0x3C. Shifts move all bits left (multiply by a power of two) or right (divide and drop the remainder).

Tips

  • Prefixes such as 0x are accepted and ignored; letters can be upper or lower case.
  • Negative results are shown with a minus sign. For a fixed-width two’s complement pattern, see the width option in the conversion tab.
  • Division gives the integer quotient and a separate remainder, as in most programming languages.

Frequently asked questions

How do I convert hex to decimal?

Multiply each digit by 16 raised to its position from the right (starting at 0) and add. For example 2F = 2 × 16 + 15 = 47.

What does FF mean in hex?

FF is 15 × 16 + 15 = 255, the largest value that fits in one byte. In binary it is 1111 1111.

Why do programmers use hexadecimal?

Each hex digit maps to exactly four bits, so long binary values become short and readable while staying easy to convert back.

What does the 0x prefix mean?

It is a common programming notation that marks a number as hexadecimal. 0x10 means hex 10, which is 16 in decimal.