100+ free calculators - no signup, no ads | 💰 Financial ❤️ Health & Fitness 📐 Math 🔧 Other
🇺🇸 USD | About Contact

Hex Arithmetic Calculator

Add, subtract, multiply, or divide hexadecimal numbers. Column workings and decimal equivalents shown.

Result (Hex)

Number Base Converter

Convert between hex, decimal, binary, and octal. Edit any field to update all others instantly.

Enter a value in any field above to convert.

Hex Colour Converter

Enter a hex colour code or RGB values to convert and preview. Supports 3 and 6 digit codes.

#
#FF5733
Red
255
Green
87
Blue
51
Red: FF = 255 · Green: 57 = 87 · Blue: 33 = 51

ASCII to Hex Encoder

Convert text to hex bytes or hex bytes back to readable text. One hex pair = one ASCII character.

H=48 e=65 l=6C l=6C o=6F

Hex Reference Table

Full conversion table: hex, decimal, binary, and octal for values 0 through FF (0 through 255).

Hex Dec Binary Oct

The Hexadecimal System

Hexadecimal uses base 16. Its sixteen digits are 0 through 9 for values zero to nine, then A through F for values ten through fifteen. Each position represents a power of 16, exactly as each position in decimal represents a power of 10.

2AA hex = (2×16²) + (A×16¹) + (A×16⁰) = (2×256) + (10×16) + (10×1) = 512 + 160 + 10 = 682 decimal

Converting Decimal to Hex

Divide the decimal number by 16 repeatedly, recording the remainder at each step. Remainders of 10 through 15 are written as A through F. Read the remainders from last to first.

Convert 1500 to hex: 1500 ÷ 16 = 93 remainder 12 (C) 93 ÷ 16 = 5 remainder 13 (D) 5 ÷ 16 = 0 remainder 5 Read bottom to top: 5DC Verify: (5×256)+(13×16)+(12×1)=1500 ✓
HexDecimalBinaryOctal
0000000
99100111
A10101012
F15111117
10160001 000020
FF2551111 1111377
1002561 0000 0000400

Hex Arithmetic

Addition

Add column by column from right to left. When a column sum exceeds F (15), subtract 16 and carry 1 to the next column. The letter digits A through F simply represent the decimal values 10 through 15.

Example: 1AB + 2F Column 1 (ones): B + F = 11+15 = 26 = 1A hex → write A, carry 1 Column 2 (16s): A + 2 + 1(carry) = 10+2+1 = 13 = D hex Column 3 (256s): 1 Result: 1DA Check: 427 + 47 = 474 = 1DA hex ✓

Subtraction

Subtract column by column. Borrow from the next column when the top digit is smaller than the bottom digit. Each borrow adds 16 to the current column (not 10 as in decimal).

Multiplication

Multiply each digit pair, convert any result above 15 by taking the quotient as a carry and the remainder as the current digit. Long multiplication with positional shifting works the same as in decimal.

ℹ️
A fast mental shortcut: each hex digit equals exactly 4 binary bits. To multiply a hex number by 16, append a 0 at the right (shift left one hex position). To multiply by 256 (16²), append two zeros. This is the hex equivalent of multiplying by 10 in decimal.

Hex Colour Codes

HTML and CSS colour codes use the format #RRGGBB, where RR, GG, and BB are two-digit hex values for the red, green, and blue channels. Each channel ranges from 00 (0) to FF (255), giving 256 possible intensities per channel and 256³ = 16,777,216 total colours.

Colour NameHex CodeRed (hex)Green (hex)Blue (hex)RGB Decimal
White#FFFFFFFF (255)FF (255)FF (255)rgb(255,255,255)
Black#00000000 (0)00 (0)00 (0)rgb(0,0,0)
Red#FF0000FF (255)00 (0)00 (0)rgb(255,0,0)
Lime#00FF0000 (0)FF (255)00 (0)rgb(0,255,0)
Blue#0000FF00 (0)00 (0)FF (255)rgb(0,0,255)
Orange-Red#FF5733FF (255)57 (87)33 (51)rgb(255,87,51)
Grey (50%)#80808080 (128)80 (128)80 (128)rgb(128,128,128)

Short Hex Codes

CSS also accepts 3-digit hex codes like #F53, where each digit is doubled to form the full code: #F53 expands to #FF5533. This works when each channel has both digits the same (e.g. #AA = #AAAA is not valid; only when both digits in each pair are identical can the pair be condensed to one digit).

💡
To find the complement of a colour, subtract each channel from FF (255). The complement of #3A6B2C is #(FF-3A)(FF-6B)(FF-2C) = #C59481D3. In hex: FF-3A = C5, FF-6B = 94, FF-2C = D3. Complement colours are directly opposite on the colour wheel.

Hex in Computing

Hexadecimal is the standard notation for raw computer data because the relationship between hex and binary is exact and compact. One hex digit always represents exactly 4 binary bits (a nibble). Two hex digits always represent exactly 8 bits (one byte). This makes it easy for humans to read and write binary data without the visual noise of long strings of 0s and 1s.

Memory Addresses

Processor and memory addresses are written in hex. A 32-bit address like 0x7FFE1234 is far more readable than 32 binary digits. Modern 64-bit systems have addresses up to 16 hex digits: 0x00007FFF7ABCDEF0. The 0x prefix indicates a hex literal in most programming languages.

ASCII and Unicode

Text encoding uses hex to represent character codes. ASCII 'A' is hex 41 (65 decimal). A space is hex 20 (32 decimal). Unicode code points are written as U+XXXX where XXXX is hex: U+00E9 is é (Latin small letter e with acute), U+1F600 is 😀 (grinning face emoji).

Network Protocols

MAC addresses use 6 bytes in hex separated by colons: 00:1A:2B:3C:4D:5E. IPv6 addresses use 8 groups of 4 hex digits: 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Network packet dumps show raw bytes in hex, making hex literacy essential for network analysis.

Machine Code and Assembly

CPU instructions and their operands are written in hex in debuggers, disassemblers, and binary editors. The x86 instruction MOV EAX, 1 compiles to the bytes B8 01 00 00 00. A hex editor shows the raw bytes of any file, which is how binary file formats are analysed and reverse-engineered.

Frequently Asked Questions

What does 0x mean before a hex number?
The 0x prefix is a notation convention used in programming languages (C, C++, Java, Python, JavaScript, and others) to indicate that the following digits are in hexadecimal. 0xFF means the hex value FF, which equals 255 in decimal. Without the prefix, FF would be misread as a variable name or cause a syntax error. In assembly language, the convention is often to suffix with h: FFh. In URLs and HTML, the prefix is %. In CSS and HTML colour codes, the prefix is #.
How do you convert a hex colour to RGB?
Split the 6-digit hex code into three 2-digit pairs and convert each from hex to decimal. Example: #4A90E2. Red = 4A = (4×16+10) = 74. Green = 90 = (9×16+0) = 144. Blue = E2 = (14×16+2) = 226. So #4A90E2 = rgb(74, 144, 226), a medium blue. The converter above does this automatically and shows the bar chart for each channel.
What is the largest 8-digit hex value?
FFFFFFFF (8 Fs) = 4,294,967,295 in decimal, which is 2³² minus 1. This is the maximum value of an unsigned 32-bit integer. In signed 32-bit representation, the maximum positive value is 7FFFFFFF = 2,147,483,647, and 80000000 through FFFFFFFF represent negative numbers in two's complement. For 64-bit: FFFFFFFFFFFFFFFF = 18,446,744,073,709,551,615 (about 1.8 × 10¹⁹).
How do you convert between hex and binary quickly?
Each hex digit maps to exactly 4 binary bits. Memorise the 16 mappings: 0=0000, 1=0001, 2=0010, 3=0011, 4=0100, 5=0101, 6=0110, 7=0111, 8=1000, 9=1001, A=1010, B=1011, C=1100, D=1101, E=1110, F=1111. To convert hex to binary, replace each digit with its 4-bit group. Example: 3F = 0011 1111. To convert binary to hex, group bits in fours from the right and replace each group: 10110101 = 1011 0101 = B5.