Skip to main content
Hex Calculator

Hex Calculator

Perform arithmetic operations directly in hexadecimal โ€” add, subtract, multiply hex numbers.

Operation
FF + 1A =
119
hex
Hex Result
119
Decimal
281
Binary
100011001

How It Works

The hex calculator performs arithmetic and bitwise operations directly on hexadecimal (base-16) numbers and instantly shows the answer in three forms at once โ€” hexadecimal, decimal (base-10), and binary (base-2). You enter two hex values, pick an operation (addition, subtraction, multiplication, integer division, or a bitwise AND), and the tool parses each value, computes the result, and converts it back. It is built for programmers, electronics and embedded-systems students, web designers working with colour codes, and anyone studying digital logic or computer-organisation courses who needs to move between number bases without doing the conversion by hand.

Hexadecimal uses sixteen symbols: the digits 0โ€“9 for the values zero through nine, and the letters A, B, C, D, E and F for ten, eleven, twelve, thirteen, fourteen and fifteen. Hex is everywhere in computing for one elegant reason โ€” each hex digit maps to exactly four binary bits (a "nibble"), so two hex digits describe a full byte (8 bits, values 0โ€“255). That tidy 4-bit correspondence makes hex a compact, human-readable stand-in for long binary strings. You will see it in memory addresses (0x7FFFโ€ฆ), HTML/CSS colour codes (#FF5733), machine code, MAC and IPv6 addresses, file-format "magic numbers", and cryptographic hashes such as SHA-256 outputs.

How base-16 arithmetic works

The calculator first converts each hex input to its underlying integer value, performs the chosen operation on those integers, then formats the answer back into hex (as well as decimal and binary). The arithmetic itself is ordinary integer arithmetic โ€” the only difference from everyday maths is the base used to write the numbers down. Addition and subtraction carry and borrow in groups of sixteen rather than ten; multiplication scales accordingly. Division here is integer-floor division (the fractional part is discarded), which matches how most programmer calculators behave, and dividing by zero is reported as undefined rather than producing a broken value. Because raw hex literals are unsigned, a negative result (for example from a subtraction) is shown with a leading minus sign on its absolute value.

Hex โ†” decimal โ†” binary conversion

Hex to decimal: multiply each digit by 16 raised to its position (counting from 0 on the right) and add them up. For example 1A = 1ร—16ยน + 10ร—16โฐ = 16 + 10 = 26, and FF = 15ร—16 + 15 = 255.

Decimal to hex: divide the number repeatedly by 16 and collect the remainders from last to first. 255 รท 16 = 15 remainder 15, and 15 in hex is F, so 255 becomes FF.

Hex to binary: expand each digit into its 4-bit pattern โ€” 0=0000, 9=1001, A=1010, F=1111 โ€” so FF = 1111 1111 = 255. The reverse simply groups the bits in fours from the right.

Bitwise AND

The AND operation compares the two numbers bit by bit: each output bit is 1 only when both corresponding input bits are 1, otherwise it is 0. So FF AND F0 = F0 (binary 1111 1111 AND 1111 0000 = 1111 0000). AND is the workhorse of bit masking โ€” it is used to isolate or clear specific bits, to test flags, and in networking to combine an IP address with a subnet mask and reveal the network portion.

Worked example

Add FF and 1A. First parse each value: FF = 255 and 1A = 26 in decimal. Add them: 255 + 26 = 281. Convert 281 back to hex by repeated division: 281 รท 16 = 17 remainder 9, then 17 รท 16 = 1 remainder 1, then 1 รท 16 = 0 remainder 1 โ€” reading the remainders bottom-up gives 119. So FF + 1A = 119 (hex), which equals 281 in decimal and 1 0001 1001 in binary. The calculator shows all three representations together.

Tips and common mistakes

Tips: a leading "0x" or "#" is just notation โ€” enter only the hex digits themselves. Remember that two hex digits equal one byte, so FF (255) is the largest value a single byte can hold. When checking colours, the six digits of #RRGGBB split into three byte pairs for red, green and blue.

Common mistakes: confusing the letter O with the digit 0 (hex has no letter O); forgetting that hex is case-insensitive so a and A mean the same thing; expecting a remainder from division when this tool floors the quotient; and treating hex subtraction results as unsigned when a smaller value minus a larger one legitimately yields a negative number. Valid characters are strictly 0โ€“9 and Aโ€“F.

Frequently Asked Questions

Hexadecimal uses 16 digits: 0โ€“9 for values zero through nine, and Aโ€“F for ten through fifteen. Each hex digit represents exactly 4 binary bits. Two hex digits represent one byte (8 bits, values 0โ€“255). This makes hex ideal for representing binary data in a compact, human-readable form.

Part of Math Tools & Converters โ€” compare every related calculator in one place.