Hex Calculator

Use this hex calculator to do hexadecimal arithmetic, bitwise operations, and base conversion with clear decimal, binary, and signed results.

Advanced options
Interpretation
Display formatting (does not change the math)
Did we solve your problem today?

How to use our Hex Calculator

  1. Choose Mode: use Hex arithmetic for math, Bitwise operation for AND or shifts, or Base conversion to convert one value between bases.
  2. Enter First value. In arithmetic and bitwise modes, type a hexadecimal whole number such as A5 or FF. In conversion mode, type the number using the Input base you selected.
  3. If needed, choose Operation. Use +, -, x, /, or mod for arithmetic. Use AND, OR, XOR, NOT, left shift, or right shift for bitwise work.
  4. Enter Second value or shift count when the chosen operation needs it. For shifts, use a whole number such as 1, 4, or 8.
  5. If you are converting, set Input base to binary, octal, decimal, or hexadecimal. In conversion mode, the operation and second value are ignored.
  6. Open Advanced options if you want to control Bit width, Signed interpretation, Prefix style, or Digit grouping.
  7. Click Calculate to see Result in hexadecimal, Result in decimal (unsigned), Result in decimal (signed) when relevant, Result in binary, and any quotient or remainder outputs.
  8. Sanity-check the answer with Parsed input summary. Make sure it matches what you meant to type, and check Warning or note for fixed-width wrap, divide-by-zero errors, or signed-value interpretation.

Definitions

Mode: The type of calculation: hex arithmetic, bitwise operation, or base conversion.

Hexadecimal: Base 16 number system using digits 0-9 and letters A-F, where A=10 through F=15.

Bit width: The number of bits kept in the result, such as 8, 16, 32, or 64. It affects wrapping and signed interpretation.

Signed interpretation: A way to read the same stored bits. Unsigned treats all bits as non-negative size, while signed uses two's complement for negatives.

Two's complement: The standard fixed-width way computers store signed integers. If the top bit is 1, the signed value can be negative.

Logical right shift: A right shift that moves bits to the right and fills the left side with 0s.

Quotient: The whole-number result of division before any remainder.

Remainder: What is left after integer division when the division is not exact.

Parsed input summary: A cleaned version of your input after validation, used to confirm the calculator read it correctly.


Common mistakes and quick fixes

Mistake: Typing 0xA5 into First value while using Hex arithmetic or Bitwise operation .
Fix: In those modes, enter plain hex digits like A5. Prefixes belong in Base conversion , where Input base tells the calculator how to read the value.

Mistake: Forgetting that Second value or shift count must be a whole number for shift operations.
Fix: For Left shift or Right shift , enter 0, 1, 2, and so on. Do not use negatives or decimals.

Mistake: Reading Result in decimal (unsigned) as if it were a signed value.
Fix: If sign matters, change Signed interpretation to Signed (two's complement) or Show both and compare it with Result in decimal (signed) .

Mistake: Ignoring Bit width during bitwise work and then wondering why the result does not match a device or program.
Fix: Set Bit width to 8, 16, 32, or 64 bits before checking Result in hexadecimal or Result in binary . Fixed-width operations can wrap.

Mistake: Expecting a decimal fraction from division when using whole-number hex math.
Fix: Read Quotient in hexadecimal and Remainder in hexadecimal . This calculator uses integer division for whole-number inputs.

Mistake: Choosing the wrong Input base in conversion mode, such as entering 255 while still set to hexadecimal.
Fix: Set Input base to the base you typed, then confirm the cleaned value in Parsed input summary .


Limitations & Key Assumptions / Boundary Conditions

  • Arithmetic and bitwise modes read inputs as hexadecimal whole numbers only. Prefixes such as 0x are not used there.
  • Base conversion accepts only valid digits for the chosen Input base. If digits do not match the base, the calculator should show an error instead of guessing.
  • Division and modulo are integer operations here. Results are shown as quotient and remainder, not decimal fractions.
  • Bitwise results use the selected Bit width. If a result exceeds that width, it wraps to fit and the note should say so.
  • Result in decimal (signed) depends on both Bit width and Signed interpretation. The same hex result can mean different signed values at different widths.
  • Right shift is treated as logical right shift, so zeros are shifted in from the left.
  • Shift counts must be whole numbers 0 or larger. Negative or fractional shift counts are invalid.
  • This tool is for integer values, not fractions, floating-point numbers, or arbitrary-width symbolic algebra.

Methodology

How the calculator works

The calculator first parses your input as an integer in the active base. In arithmetic and bitwise modes, inputs are hexadecimal. In conversion mode, the selected Input base controls parsing.

N = sum(d_i * b^i)

Here, N is the value, d_i is each digit, and b is the base. For hex, the digit values are 0-9 and A-F, where A=10 through F=15.

Arithmetic mode

For add, subtract, multiply, divide, and remainder, the calculator converts the hex inputs to integers, performs the operation, then formats the result back into hexadecimal, decimal, and binary.

result = op(parse_base16(A), parse_base16(B))

Division uses whole-number integer division. That means the tool reports a quotient and a remainder instead of a decimal fraction.

Base conversion mode

After parsing the input in the chosen base, the calculator rewrites the same integer in base 16, base 10, and base 2.

q_0 = N; q_{k+1} = floor(q_k / b); r_k = q_k mod b

The remainders are read in reverse order to form the digits of the new base.

Bitwise mode and width control

Bitwise operations use a fixed width so results match common computer integer sizes. The calculator builds a width mask and wraps the result to that width when needed.

mask = 2^w - 1; wrapped = x mod 2^w

For left shift, bits moved past the selected width are discarded. For right shift, the calculator uses logical right shift.

left_shift = (x * 2^k) mod 2^w

right_shift_logical = floor(x / 2^k)

Signed vs unsigned results

The same bit pattern can be read two ways. Unsigned reads it as a non-negative integer. Signed reads it with two's complement inside the selected width.

signed(x,w) = x if x < 2^(w-1), else x - 2^w

Example: in 8 bits, 0xF0 is 240 unsigned, but it is -16 signed.

Mini example

Suppose you divide FF by 10 in hex arithmetic mode. FF is 255 in decimal, and 10 is 16 in decimal. Integer division gives 15 remainder 15, so the outputs are quotient 0xF and remainder 0xF.

Another example: with 8-bit width, ~0F becomes F0. That is 240 as Result in decimal (unsigned) and -16 as Result in decimal (signed).

Assumptions behind the results

This calculator assumes whole-number math, logical right shift, and fixed-width wrapping for bitwise results. If you expected signed arithmetic right shift, fractional division, or unlimited-width integers, your result may differ from this tool.


Sources