Hex Calculator: Add, Convert and Colour Codes
Add, subtract, multiply and divide hexadecimal numbers, convert to decimal or binary, and read RGB colour codes. The Hex Calculator shows every carry in base 16.
Results update as you type. Ctrl/Cmd+Enter copies the primary result.
Result
—
Bit view
Show the working
The Hex Calculator adds, subtracts, multiplies and divides hexadecimal values, converts among hex, decimal and binary, and formats results with an optional 0x prefix. Digits run from 0 to 9 and A to F, where A is 10 and F is 15. Worked arithmetic uses the same carry and borrow rules as decimal, with a threshold of 16 instead of 10, so colour channels and memory addresses can be checked without a separate scratch pad.
All calculation runs in your browser. Nothing you enter is sent to a server.
Add, subtract, multiply and divide hexadecimal numbers
Hexadecimal arithmetic is base-16 column math with digits 0 to 9 and A to F. Enter two hex strings, pick an operation, and the Hex Calculator returns the hex result with a decimal confirmation beside it. Letter digits may be typed in either case; output normalises to uppercase unless a style toggle says otherwise.
Carries fire when a column reaches 16 or more. Borrows pull 16 from the next higher digit. Multiplication and division use the same long-form layout as decimal, with intermediate products looked up from the hex multiplication table. Digits outside 0 to 9 and A to F are rejected before any operation runs.
Convert hexadecimal to decimal
Positional expansion multiplies each hex digit by a power of 16. The rightmost place is 16⁰ (ones), then 16¹ (sixteens), 16² (256), 16³ (4096), and higher powers as needed. Digit letters convert to their decimal values first: A=10, B=11, C=12, D=13, E=14, F=15.
For 2F:
2 F
│ └─ 15 × 16⁰ = 15
└─── 2 × 16¹ = 32
= 47
FF is 15×16 + 15 = 255, the maximum unsigned 8-bit value and the familiar full channel in an RGB triplet. The calculator prints the expansion for every conversion so a misread letter is caught early.
Convert decimal to hexadecimal
Repeated division by 16 produces hex digits as remainders. Divide the decimal value by 16, record the remainder, and continue with the quotient until it reaches zero. Remainders from 10 to 15 become the letter digits A to F. Reading the remainders from last to first yields the hexadecimal string the Hex Calculator also prints for a check.
For decimal 47:
| Step | Quotient | Remainder |
|---|---|---|
| 47 ÷ 16 | 2 | 15 (F) |
| 2 ÷ 16 | 0 | 2 |
Reading upward yields 2F. Large integers follow the same loop; only the number of steps grows. Round-tripping decimal to hex and back through the calculator is a quick sanity check before pasting a value into a debugger or CSS colour field.
Add 8AB and B78 in hex
Adding 8AB and B78 is the fixture for hex column addition with carries across letter digits. In decimal, 0x8AB is 2219 and 0xB78 is 2936. Their sum is 5155, which writes as 1423 in hex. Each column that reaches 16 or more writes a carry of 1 into the next higher place, exactly as decimal carrying works at ten.
1 1 carries (decimal)
8 A B 2219
+ B 7 8 2936
-------
1 4 2 3 5155
Rightmost column: B + 8 = 11 + 8 = 19 decimal = 13 hex, write 1. Write 3, carry 1. Middle column: A + 7 + carry 1 = 10 + 7 + 1 = 18 decimal = 12 hex, write 1. Write 2, carry 1. Left column: 8 + B + carry 1 = 8 + 11 + 1 = 20 decimal = 14 hex (14). Write 4, and the remaining carry writes the leading 1.
The result 1423 matches 1×4096 + 4×256 + 2×16 + 3 = 5155. The Hex Calculator renders this carry view for each addition so the hand check and the tool agree.
Subtract with borrowing in hex
Hex subtraction borrows 16 decimal, one full sixteen, when a digit is smaller than the digit beneath it. The lender in the next higher place drops by 1, and the current digit gains 16 before the subtraction proceeds. The fixture 5DC minus 3AF demonstrates a clean positive result of 22D with that borrow rule applied once in the low column.
5 D C 1500 decimal
- 3 A F 943 decimal
-------
2 2 D 557 decimal
Rightmost: C (12) minus F (15) cannot proceed, so borrow from D. The low digit becomes 12 + 16 = 28, and D drops to C. Then 28 − 15 = 13, which is D. Middle: C (after lending) minus A is 12 − 10 = 2. Left: 5 − 3 = 2.
The difference is 22D. When the subtrahend is larger and a bit width is set, the calculator can report a wrapped two's complement style result for fixed-width registers; unbounded mode keeps a signed magnitude without inventing a register size.
Convert between hex and binary directly
Each hex digit maps to exactly four bits, one nibble, with no leftover. That fixed mapping is why hex dumps stay compact and why an RGB pair such as FF is eight ones in binary. Expanding or compressing between the two bases needs only the nibble table, and the Hex Calculator performs both directions for any valid string.
| Hex | Binary | Decimal |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| A | 1010 | 10 |
| F | 1111 | 15 |
2F becomes 0010 1111. FF becomes 1111 1111. Expanding a byte as two hex digits, or compressing eight bits into two hex digits, needs no arithmetic beyond the table. The Hex Calculator performs that mapping in both directions; place-value teaching and bitwise tutorials live on the Binary Calculator page so the two tools do not repeat each other.
Read hex colour codes
CSS and design tools write colours as #RRGGBB, where each pair is an 8-bit channel from 00 (0) to FF (255). #FF5733 means red 255, green 87, blue 51. An optional alpha channel adds a fourth pair (#RRGGBBAA) for opacity, still using the same 00 to FF scale.
| Code | Red | Green | Blue |
|---|---|---|---|
| #000000 | 0 | 0 | 0 |
| #FFFFFF | 255 | 255 | 255 |
| #FF0000 | 255 | 0 | 0 |
| #00FF00 | 0 | 255 | 0 |
| #0000FF | 0 | 0 | 255 |
| #FF5733 | 255 | 87 | 51 |
Mixing channels is ordinary hex arithmetic on each pair independently. Brightening a channel means adding toward FF; dimming means subtracting toward 00. The calculator accepts bare hex or # prefixed strings when converting channels to decimal for comparison against a palette spec.
Read memory addresses and byte values
Debuggers and language runtimes print pointers and machine values in hex with a 0x prefix: 0x7FFE looks shorter than the decimal equivalent and lines up with byte boundaries. A memory dump is usually a grid of bytes, two hex digits each. Words (16-bit), double words (32-bit) and quad words (64-bit) are groups of those bytes.
Endianness decides the byte order inside a multi-byte word. Little-endian stores the least significant byte at the lowest address; big-endian stores the most significant byte first. Reading 0x1234 from memory as bytes 34 12 is little-endian. Confusing the order produces addresses and integers that look plausible until compared against a register view. The Hex Calculator converts the numeric value; interpreting a dump still requires knowing which endianness the target uses.
Read the hexadecimal multiplication table
Products of single hex digits stay small enough to memorise for hand arithmetic and long multiplication. Rows and columns run from 1 through F, and each cell holds the product written in hex. Looking up A × B or F × F removes the need to convert to decimal mid-step when multiplying multi-digit hex values by hand.
| × | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2 | 2 | 4 | 6 | 8 | A | C | E | 10 | 12 | 14 | 16 | 18 | 1A | 1C | 1E |
| 4 | 4 | 8 | C | 10 | 14 | 18 | 1C | 20 | 24 | 28 | 2C | 30 | 34 | 38 | 3C |
| 8 | 8 | 10 | 18 | 20 | 28 | 30 | 38 | 40 | 48 | 50 | 58 | 60 | 68 | 70 | 78 |
| A | A | 14 | 1E | 28 | 32 | 3C | 46 | 50 | 5A | 64 | 6E | 78 | 82 | 8C | 96 |
| F | F | 1E | 2D | 3C | 4B | 5A | 69 | 78 | 87 | 96 | A5 | B4 | C3 | D2 | E1 |
F × F = E1 because 15 × 15 = 225 and 225 = 14×16 + 1. Long multiplication of multi-digit hex numbers is built from these single-digit products plus hex addition of the shifted partial sums. The calculator performs that work automatically and still exposes the decimal check for verification.
Frequently asked questions
What digits does hexadecimal use?
Hexadecimal uses 0 to 9 and A to F. A stands for 10, B for 11, C for 12, D for 13, E for 14 and F for 15. Each digit is one place in base 16, so 10 in hex is sixteen in decimal, not ten.
How do you convert hex to decimal?
Multiply each digit by its power of 16 and add. The rightmost digit is worth 1, the next 16, then 256, then 4096. Convert letter digits to 10 through 15 first. 2F is 2×16 + 15 = 47.
Why do programmers prefer hex over decimal for bytes?
One hex digit is exactly four bits, so two hex digits are exactly one byte. That alignment makes masks, colour channels and memory dumps readable without converting every bit. Decimal values hide those boundaries.
What does the 0x prefix mean?
The 0x prefix is a notation convention, common in C and related languages, marking the following digits as hexadecimal. 0xFF and FF are the same value to the calculator; the prefix is optional on input and available on output for pasting into code.
How does hex relate to RGB colour codes?
An #RRGGBB colour stores each channel as two hex digits from 00 to FF. #FF5733 is red 255, green 87, blue 51. Alpha, when present, is a fourth pair with the same range.
What is endianness?
Endianness is the byte order used to store a multi-byte value in memory. Little-endian puts the least significant byte at the lowest address; big-endian puts the most significant byte first. The same hex integer can appear as different byte sequences depending on the machine.
How do you subtract hex numbers with a borrow?
When a digit is smaller than the one being subtracted, borrow 16 from the next higher digit. The current digit increases by 16 (decimal), and the lender decreases by 1. 5DC − 3AF = 22D uses that rule in the low column.
Can hex convert directly to binary without decimal?
Yes. Replace each hex digit with its four-bit pattern. A becomes 1010, F becomes 1111, and so on. Concatenate the nibbles to get the full binary string. No decimal intermediate is required.
What is FF in decimal?
FF hex is 15×16 + 15 = 255 decimal. It is the largest unsigned 8-bit value and the "full on" level for a single colour channel.
Does the Hex Calculator upload values?
No. Conversion and arithmetic run entirely in the browser. Addresses, colour codes and dump fragments stay on the device.
Summary
The Hex Calculator performs base-16 arithmetic, converts among hex, decimal and binary through powers of 16 and the four-bit nibble map, and supports colour-channel and memory-oriented reading of hex strings. Adding 8AB and B78 yields 1423; subtracting 3AF from 5DC yields 22D.
RGB codes, 0x addresses and endianness-aware dump reading are covered here; bitwise place-value teaching stays on the Binary Calculator so the two pages stay distinct.