AdSense Placeholder
Slot: header_tool

Hex Calculator

Arithmetic & Bitwise Operations

--
--
AdSense Placeholder
Slot: tool_mid_article

Working With Hexadecimal Numbers

Hexadecimal (base-16) is the standard shorthand for binary data in programming, memory addressing, and color codes — each hex digit maps cleanly to exactly four bits. This calculator lets you add, subtract, multiply, and divide hex values, and also perform the bitwise logic operations used directly in low-level code.

Arithmetic Operations

Add, subtract, multiply, and divide hex numbers exactly as you would decimal numbers — the calculator converts internally, performs the math, and converts the result back into hexadecimal.

Bitwise Logic

AND, OR, XOR, and NOT compare or invert the underlying bits — commonly used with hex values for color manipulation, memory masks, and register flags.

Why Bit Width Matters

Hex digits don't carry a fixed bit length on their own — A and 0A represent the same decimal value (10), but a bitwise NOT of each gives a very different-looking answer depending on how many bits you consider. Fixing the bit width to 8, 16, or 32 bits before running NOT or a shift keeps the operation well-defined and matches how real hardware registers behave.

Key Takeaways

  • Every hex digit represents exactly four bits, making hex a compact, human-friendly way to write binary data.
  • Arithmetic and bitwise operations answer different questions. Arithmetic treats hex as a quantity; bitwise treats it as a sequence of independent bits.
  • The decimal equivalent is always shown alongside the hex result, so you can sanity-check your work without switching tools.

Frequently Asked Questions

  1. Enter the first hexadecimal number (Operand A) using digits 0-9 and letters A-F.
  2. Choose an operation — arithmetic (add, subtract, multiply, divide) or bitwise (AND, OR, XOR, NOT, left shift, right shift).
  3. Enter the second hexadecimal number (Operand B), unless you selected NOT, which only needs one operand.
  4. Click "Calculate" to see the hex result along with its decimal equivalent.

Arithmetic operations (add, subtract, multiply, divide) treat hexadecimal numbers as ordinary quantities and produce the same result you'd get doing the math in decimal, just expressed in base-16. Bitwise operations (AND, OR, XOR, NOT, shifts) instead act on the underlying binary bits of each number, comparing or moving them position by position — these are the operations used directly in memory masks, color values, and low-level programming.

Bitwise operations like NOT and the shifts are only meaningful within a fixed number of bits, since flipping every bit of a value technically requires knowing how many bits it occupies. The Bit Width selector (8, 16, or 32 bits) sets that fixed width — for example, NOT on 0A at 8-bit width gives F5, but the same NOT at 16-bit width gives FFF5.

A left shift moves the underlying bits of the value to the left, filling vacated positions with zeros — equivalent to multiplying by 2 for every position shifted. A right shift moves the bits to the right, equivalent to dividing by 2 (rounding down) for every position shifted. The Shift Amount operand tells the calculator how many positions to move.

This tool is built for performing arithmetic and bitwise operations on hexadecimal numbers, not pure base conversion. If you just need to convert a value between hex and decimal without doing any math on it, use our dedicated Hex to Decimal and Decimal to Hex converters instead.

The calculator only accepts the digits 0-9 and letters A-F for hex operands and will show a clear error if anything else is entered. Dividing by a hex value equal to zero is also caught and reported as an error rather than producing an incorrect result.

AdSense Placeholder
Slot: footer_leaderboard