What hex actually is, and why it exists
A computer stores everything as binary, strings of nothing but 0s and 1s, because that maps directly onto a transistor being off or on. The trouble is that binary is dreadful for a person to read: a perfectly ordinary number like 755 is 1011110011 in binary, ten digits where most of the information is just noise to a human eye. Hexadecimal, base 16, was adopted as a shorthand that a person can actually parse, because it lines up with binary in a uniquely tidy way: every hex digit stands for exactly four binary digits (bits), no remainder, no carrying between groups. That single fact is the whole reason hex exists. Four bits can hold sixteen possible patterns, 0000 up to 1111, so hex needs sixteen symbols to match; run out of ordinary digits after 9 and the alphabet steps in, A for ten through F for fifteen.
That grouping is why programmers write memory dumps, colour codes and error flags in hex rather than in binary or even decimal: a byte that would take eight binary digits or up to three decimal digits to write is exactly two hex digits, and converting between the two forms is a lookup, not a calculation.
Where you actually run into hex
Hex rarely announces itself, but it turns up more often than most people realise. A web page's colour is set with a six-digit hex code such as #1A6B48, two digits each for red, green and blue. A crash report or device driver error often prints a hex code, such as 0x0000007B, because it is really a small number describing which fault occurred, just formatted the way the operating system's own internals think in. A computer's memory addresses, the numbered pigeonholes data lives in, are conventionally written in hex because they map so directly onto the underlying binary layout. A network card's MAC address, the fixed serial number every device on a network carries, is written as six hex byte-pairs, such as 3C:22:FB:4A:9B:01, again because it is fundamentally a 48-bit binary value that nobody would want to read as forty-eight 0s and 1s.
Getting past the letters-as-digits hurdle
The part of hex that trips people up first is treating a letter as a number. It helps to remember there is nothing mystical about it: A, B, C, D, E and F are simply the digit symbols for ten, eleven, twelve, thirteen, fourteen and fifteen, chosen because decimal ran out of digits at nine. Reading FF is no different in principle to reading 99 in decimal, both are "as high as this digit position goes, twice in a row". This calculator treats uppercase and lowercase the same way throughout, so a3, A3 and typing it half and half all mean the identical value; hex has no concept of case, the letters just happen to render more clearly in capitals on most screens, which is the convention this tool displays results in.
How the arithmetic tab works
Adding, subtracting, multiplying and dividing two hex numbers follows exactly the same logic as doing it in decimal, the only difference is that each digit position is worth a power of 16 instead of a power of 10, and a carry or borrow fires once a digit position would need to hold 16 or more instead of 10 or more. Rather than working entirely in hex digit-by-digit, this tool takes the more transparent route for the working shown on screen: it converts both hex numbers to their exact decimal value using the place-value method below, does the sum in decimal, then converts the answer back to hex. The result is identical to working in hex directly, but the decimal middle step is far easier to check by eye.
Division works the same way and always returns two figures, a quotient and a remainder, because hex division is whole-number (integer) division here rather than a decimal expansion: 1A3 (hex, 419 in decimal) divided by B (hex, 11 in decimal) gives a quotient of 26 (hex, 38 in decimal) with 1 left over, because 11 fits into 419 exactly 38 times with a remainder of 1. Subtraction can produce a negative result if the second number is larger than the first, shown with a plain minus sign on both the hex and decimal answer; this tool works in ordinary signed arithmetic rather than the fixed-width wraparound a processor uses internally.
Converting hex to decimal: the place-value method
Every number system, whatever its base, works by place value: each position in the number is worth the base raised to a power, starting at power 0 on the right and climbing by one with every step left. In hex that means the rightmost digit is worth 16 to the power 0 (which is 1), the next is worth 16 to the power 1 (16), then 16 squared (256), then 16 cubed (4,096), and so on. Multiply each digit by the value of its position and add the results together, and the decimal total falls out.
Worked out for 2F3: the 2 sits in the 16² position, worth 256, so it contributes 2 × 256 = 512; the F sits in the 16¹ position, worth 16, and F stands for 15, so it contributes 15 × 16 = 240; the 3 sits in the 16⁰ position, worth 1, contributing 3 × 1 = 3. Add 512, 240 and 3 and the total is 755, exactly what the Hex to decimal tab above shows for the same input.
Converting decimal to hex: repeated division
Going the other way uses a short, mechanical routine: divide the decimal number by 16, note the remainder, then divide the quotient by 16 again, note that remainder too, and keep going until the quotient reaches 0. Reading the remainders from the last one found back up to the first gives the hex digits in the right order.
It can feel backwards the first time, because the digit found first (3) ends up on the right, the last one found (2) ends up on the left, but that is simply because each division peels off the smallest place value first, working from the ones place outward, exactly the mirror image of building the number up by place value.
The nibble table: hex and binary side by side
Because one hex digit always equals exactly four bits, a "nibble", every one of the sixteen hex digits has one fixed four-bit binary pattern, and it is worth knowing a few by sight: A is 1010, F is every bit switched on, 1111, and 8 is a single leading 1 followed by three 0s, 1000. That fixed mapping is as far as binary needs to come into a hex conversion; no carrying or borrowing is involved, just a lookup.
| Decimal | Hex digit | 4-bit binary |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 2 | 0010 |
| 3 | 3 | 0011 |
| 4 | 4 | 0100 |
| 5 | 5 | 0101 |
| 6 | 6 | 0110 |
| 7 | 7 | 0111 |
| 8 | 8 | 1000 |
| 9 | 9 | 1001 |
| 10 | A | 1010 |
| 11 | B | 1011 |
| 12 | C | 1100 |
| 13 | D | 1101 |
| 14 | E | 1110 |
| 15 | F | 1111 |
Hex colours: reading #RRGGBB
A web colour such as #1A6B48 is three hex-to-decimal conversions stacked together: the first pair of digits, 1A, is the red channel; the middle pair, 6B, is green; the last pair, 48, is blue. Each channel runs from 00 (none of that colour) to FF (full intensity, 255 in decimal), so #1A6B48 means red 26, green 107, blue 72 out of 255 each, a muted forest green. Try the six-digit box in the panel to the right, or its three-digit shorthand: a code such as #1A6 is shorthand for #11AA66, each digit doubled up, which only works when both digits in every channel would have matched anyway.
Common mistakes
- Typing the letter O instead of the digit 0. They look almost identical in many fonts, but hex has no letter O; only the digit 0 (zero) is valid, and this tool flags it by name when it spots one.
- Assuming hex is case-sensitive. It is not. FF, ff and Ff are exactly the same value; this tool accepts any mixture and simply displays its answers in uppercase.
- Reading E as a letter rather than the digit fourteen. Unlike scientific notation's "E" for exponent, a hex E in a plain hex number is just the digit worth 14, nothing more.
- Forgetting the 0x is not part of the value. 0xA3 and A3 are the same number; the 0x is only a label some programming languages use to mark "this is hex", and this tool strips it automatically.
Questions people ask
What is hexadecimal and why do computers use it?
Hexadecimal is a base-16 number system using the digits 0-9 and the letters A-F for ten through fifteen. Computers work in binary, but binary is long and hard to read, and hex is used as a human-friendly shorthand because one hex digit always equals exactly four binary digits, with no remainder to carry between groups.
How do you convert hex to decimal?
Multiply each digit by 16 raised to the power of its position, counting from 0 on the right, then add the results. For 2F3, that is (2 × 256) + (15 × 16) + (3 × 1), which is 512 + 240 + 3 = 755.
How do you convert decimal to hex?
Divide the decimal number by 16 repeatedly, noting the remainder each time, until the quotient reaches 0. Reading the remainders from the last one found back to the first gives the hex digits in order: 755 becomes 47 remainder 3, then 2 remainder 15 (F), then 0 remainder 2, read upward as 2F3.
Is hex case-sensitive, does AB differ from ab?
No. Hexadecimal has no concept of upper or lower case; AB and ab are the identical value, 171 in decimal. This calculator accepts either, or a mixture, and displays its own results in uppercase.
What does the 0x in front of a hex number mean?
0x is a prefix used by many programming languages purely to mark "the following digits are hexadecimal"; it carries no value of its own. 0xA3 and A3 refer to exactly the same number, and this tool accepts either form, stripping the prefix before it calculates.
How does a hex colour code like #1A6B48 work?
The six digits split into three pairs, each a value from 00 to FF (0 to 255 in decimal) for red, green and blue in that order. #1A6B48 means red 26, green 107 and blue 72. A three-digit shorthand such as #1A6 is also accepted; each digit is doubled to expand it, so #1A6 means the same as #11AA66.
What is a hex digit worth in binary?
Exactly four bits, called a nibble. A is 1010, F is 1111 (every bit on), and 8 is 1000. Two hex digits together make one byte, eight bits, which is why hex is written in pairs for colours, MAC addresses and memory bytes.
All three tabs use JavaScript's BigInt type under the hood, so a number is never rounded through an ordinary floating-point value; the practical limit is 16 significant hex digits per typed field (up to F,FFF,FFF,FFF,FFF,FFF in hex, roughly 18.4 quintillion in decimal), a wide enough range to cover any everyday colour code, memory address or error flag.