Hex Calculator

Enter two hexadecimal numbers and an operation.

Hexadecimal Arithmetic Guide

Hex digits

Hexadecimal is base-16. Digits 0�9 represent values 0�9; A�F represent 10�15.

Hex digit values

HexDecimalBinary
A101010
B111011
C121100
D131101
E141110
F151111

Related Calculators

Hexadecimal in Everyday Computing

Hex (base-16) uses digits 0–9 and letters A–F. It appears everywhere in computing: HTML/CSS colour codes (#3A86FF), MAC addresses (00:1A:2B:3C:4D:5E), IPv6 addresses (2001:0db8:85a3::8a2e:0370:7334), file format magic numbers (PDF files start with 25 50 44 46), and debugger memory views. Two hex digits represent exactly one byte (0–255), making hex the most compact human-readable byte format. When a programmer writes 0xFF in code, they mean the decimal value 255.

Hex Arithmetic Rules

Hex addition carries at 16. For example: A + 7 = 17 (decimal) = 11 in hex (write 1, carry 1). Hex multiplication follows the same pattern. Most programmers use hex calculators rather than doing this by hand, but understanding the basics helps when reading binary dumps, writing assembly code, or interpreting network packets.

Hex expressionDecimal value
0xFF255
0x1016
0xDEAD57,005
0xFFFF65,535

Hexadecimal Arithmetic Operations

Hex arithmetic follows the same rules as decimal but with base 16. To add in hex: work right to left, adding digit values; when the sum reaches 16 or more, carry 1 to the next column. A + 7 = 17 decimal = 11 hex (write 1, carry 1). Subtraction in hex borrows 16 (not 10) when needed. Multiplication follows the same pattern, just using hex tables. Calculators handle these operations automatically, but understanding the process helps debug assembly code and embedded systems.

Hex calculators are essential tools for programmers working with memory addresses, bit masks, color values, and protocol headers. A common task is computing bit masks: to set bits 0, 2, and 4 of a register, use 0x15 (binary 00010101). To clear bit 3, use the mask 0xF7 (binary 11110111). AND, OR, XOR, and NOT operations on hex values control hardware registers, network packets, and cryptographic algorithms.

Hex Digit Addition Table (partial)

+89ABC
81011121314
91112131415
A1213141516
B1314151617

Working with Hexadecimal in Programming

Hexadecimal arithmetic is a routine skill for programmers working with binary data, memory addresses, and hardware registers. When adding two hex numbers, carry occurs whenever a column sum exceeds F (15 in decimal). For example, A plus 7 equals 17 in decimal, which is 11 in hexadecimal: write 1 and carry 1. Subtraction in hex borrows from the next column, where a borrow is worth 16 (not 10 as in decimal). Multiplying hex numbers directly requires knowledge of the hex multiplication table, but most developers convert to decimal, multiply, and convert back for complex multiplications. Bitwise AND, OR, XOR, and NOT operations are applied directly to hex digits because each digit maps exactly to a four-bit nibble. For instance, F AND 5 in hex is 1111 AND 0101 in binary, which equals 0101 or 5. Hex is the natural notation for color values: HTML color #3A7FBB represents red channel 3A (58 decimal), green 7F (127 decimal), and blue BB (187 decimal). Understanding hex arithmetic helps developers manipulate colors, flags, and data masks precisely without a calculator.

Hex Arithmetic Reference Table

Hex operationResult (hex)Decimal check
A + 61010 + 6 = 16
FF + 1100255 + 1 = 256
1F − A1531 − 10 = 21
F AND 5515 AND 5 = 5
A OR 5F10 OR 5 = 15
FF XOR 0FF0255 XOR 15 = 240
Have Feedback or a Suggestion? Contact Us
Top