Hex Calculator

Free hex calculator: add, subtract, multiply, divide, AND/OR/XOR, NOT, shift, and convert between hex, decimal and binary. Works in any base for both operands.

How to Calculate Hexadecimal?

Hexadecimal (base-16) is a number system that uses 16 symbols: 0-9 and A-F. It's commonly used in computer programming and digital systems. Each position represents a power of 16.

Converting Hexadecimal to Decimal:

  • Write down the hexadecimal number
  • Multiply each digit by 16 raised to the power of its position (from right to left, starting at 0)
  • Add all the results together

0xFF = 15×16¹ + 15×16⁰ = 240 + 15 = 255

Converting Decimal to Hexadecimal:

  • Divide the decimal number by 16
  • Write down the remainder (convert 10-15 to A-F)
  • Continue dividing the quotient by 16 until it becomes 0

255 ÷ 16 = 15 remainder 15 → F

15 ÷ 16 = 0 remainder 15 → F

Result: 0xFF

Hexadecimal reference table

DecimalHexadecimalBinary
00x00000
10x10001
100xA1010
150xF1111
160x1010000
2550xFF11111111
2560x100100000000

About this hex calculator

Enter two numbers in any combination of bases — hex, decimal, or binary — pick an operation, and the calculator returns the result simultaneously in hex, decimal and binary. Arithmetic operations (+, −, ×, ÷, exponent) are handled with BigInt, so very large hex values like 0xFFFFFFFFFFFFFFFF work without precision loss. Bitwise operations (AND, OR, XOR, NOT, left shift, right shift) operate on the integer representation, matching what C/JavaScript/Python would compute on the same inputs. Everything runs in your browser — no inputs are uploaded.

Frequently Asked Questions

Read the hex digits from right to left, multiplying each by an increasing power of 16. For 0xFF: F×16¹ + F×16⁰ = 15·16 + 15·1 = 240 + 15 = 255. For longer values like 0x1A2B: 1·16³ + 10·16² + 2·16¹ + 11·16⁰ = 4096 + 2560 + 32 + 11 = 6699. The calculator does the conversion in one step — pick 'Hex' as the input base, type the value, and the decimal result shows underneath.

Repeatedly divide the decimal number by 16, recording each remainder. The remainders read bottom-to-top form the hex value, with 10–15 written as A–F. Example for 255: 255 ÷ 16 = 15 remainder 15 (F); 15 ÷ 16 = 0 remainder 15 (F). Read bottom-to-top: FF. So 255 = 0xFF. The calculator converts in either direction — pick the source base on the input dropdown and the result appears in all three bases.

Bitwise AND, OR, XOR operate on the binary representations of the inputs, one bit at a time. 0xFF AND 0x0F: in binary 11111111 AND 00001111 = 00001111 = 0x0F (keeps only the low nibble). 0xA0 OR 0x0B: 10100000 OR 00001011 = 10101011 = 0xAB (combines bits). 0xFF XOR 0x0F: 11111111 XOR 00001111 = 11110000 = 0xF0 (flips bits where the second operand has 1s). These are the building blocks of bit-mask programming and color-channel tricks.

Left shift by n moves all bits left by n positions and fills the right with zeros — equivalent to multiplying by 2ⁿ. 0x0F << 4 = 0xF0 (a one-nibble left shift). Right shift by n moves bits right and discards what falls off the end — equivalent to integer-dividing by 2ⁿ. 0xFF >> 4 = 0x0F. Shifts are how you pack and unpack RGB color channels (red = (color >> 16) & 0xFF), parse binary file formats, and implement fast multiplies/divides by powers of two.

Each pair of hex digits encodes a value 00–FF (0–255), giving the intensity of one color channel. #FF0000 is pure red (R=255, G=0, B=0); #00FF00 is pure green; #FFFFFF is white. Three bytes pack into six hex digits exactly, which is why the format is universal in CSS, design tools, and graphics APIs. Using hex instead of decimal keeps each channel visually distinct (#FF6347 vs rgb(255, 99, 71)) and makes bit-masking each channel trivial.

No. 0x10 is hexadecimal sixteen — the '0x' prefix tells the reader (and the compiler) that the digits are base-16. Plain 10 is decimal ten. The same digits can mean different values depending on the base: 10 in binary is 2, 10 in hex is 16, 10 in decimal is 10. The calculator's input dropdown next to each number lets you state the base explicitly, so there is never ambiguity about how a value is interpreted.

Yes. All arithmetic uses JavaScript's BigInt, which has no fixed bit-width limit. You can compute 0xFFFFFFFFFFFFFFFF + 1 = 0x10000000000000000 (17 hex digits) or shift much larger values without overflow. Bitwise operations on BigInt behave like operating on two's-complement integers extended to arbitrary precision, so AND/OR/XOR/NOT also work correctly on 128-bit, 256-bit, or larger inputs.

Memory addresses are usually printed in hex (a pointer like 0x7fff5fbff7c0 is easier to scan than its 13-digit decimal form). Bit flags and permission masks use hex constants (Unix file modes like 0644, register flag bits like 0x80000000). Cryptography hashes and UUIDs are shown in hex. Color values in CSS, asset IDs in game engines, opcodes in disassemblers, and error codes in Windows (0x80070005 'access denied') are all hex. This calculator is designed for the kinds of arithmetic you do while debugging or reading documentation on any of those.
Hex Calculator — Free hex calculator: add, subtract, multiply, divide, AND/OR/XOR, NOT, shift, and convert between hex, decimal and binar
Hex Calculator