Math & Statistics · Number Bases · Free

Hex Calculator

Do math directly on hexadecimal numbers. Type two base-16 values, choose an operation — add (+), sub (-), mult (×), div (÷), modulo (mod), exp (^), and (&), or (|), not (~), xor (^), left shift (<<), right shift (>>) or zerofill right shift (>>) — and press Calculate to see the hex, decimal and binary result with full calculation steps. Everything runs locally in your browser.

STEP 1

Enter the first hex number

Type a base-16 value using digits 0-9 and letters A-F, e.g. FF (= 255 in decimal). A leading minus sign and hex fractions are allowed, e.g. -3 or A.B. Invalid characters (including a 0x prefix or spaces) are highlighted in red and clear the previous result.

STEP 2

Pick an operation (and the 2nd number)

Choose from add, sub, mult, div, mod, exp, and, or, not, xor, left shift, right shift, or zerofill right shift. Only not (~) needs no second number. For shifts the second field is the shift count as a hex integer, e.g. 4 means shift by 4.

STEP 3

Press Calculate, read three bases

The result appears in hex, decimal and binary, plus the calculation steps, e.g. FF + FF = 255 + 255 = 510 = 1FE₁₆. Tick Digit grouping to space the digits (1 234 567), and copy any result with its Copy button.

Hex arithmetic and bitwise operations

Hex addition example
Read each value as a power of 16 first: FF₁₆ + FF₁₆ = 255₁₀ + 255₁₀ = 510₁₀ = 1FE₁₆. The same decimal bridge works for subtraction, multiplication and division — the calculation steps panel shows every step. Division can produce fractional hex, e.g. FF ÷ 2 = 127.5 = 7F.8₁₆.
Bitwise operations are limited to 32 bits
and (&), or (|), not (~) and xor (^) convert each input with parseInt(x, 16) and apply 32-bit integer logic, just like JavaScript — longer values wrap to their low 32 bits. Results print signed, e.g. FFFFFFFF and 80000000 = -80000000₁₆, while not (~) renders the unsigned complement: ~FF = FFFFFF00 = 4294967040.
How the shifts work
Left shift (<<) multiplies by 2 to the power of the shift count and right shift (>>) divides by it: FF << 4 = 255 × 2⁴ = 4080 = FF0₁₆, and 1 >> 1 = 0.5 = 0.8₁₆. Because right shift is a true division it keeps fractions instead of discarding bits. Zerofill right shift (>>) performs 32-bit unsigned logical right shift (x >>> n), shifting bits to the right and zero-filling from the left: -1 >>> 1 = 7FFFFFFF₁₆ = 2147483647.
What inputs does the calculator reject?
Anything outside an optional minus sign, hex digits and one point — letters G-Z, spaces, or a 0x prefix. The bad field is highlighted and all results clear, so a stale result never survives a bad edit. A non-integer exponent shows "Please enter integer exponent"; a negative or fractional shift count is rejected. Dividing by zero returns Infinity and modulo by zero returns NaN.
When are results padded or grouped?
For and, or, not and xor a non-negative hex result is zero-padded to the wider input, so FF00 and 0FF0 shows 0F00. With Digit grouping on, hex is grouped in 2s, decimal in 3s and binary in 4s: 1FE becomes 1 FE and 510 stays 510.

More number work: browse all Math & Statistics tools.

Privacy: every calculation runs in your browser tab — no value you type is sent anywhere. Copy result uses your clipboard only. Bitwise ops follow 32-bit integer semantics; arithmetic runs on exact base-16 fractions.