Hex Calculator
Perform hexadecimal addition, subtraction, multiplication, and division with full step-by-step working, decimal cross-check, and binary, octal, and scientific notation conversions in one card.
Hex Arithmetic — Add, Subtract, Multiply, Divide
Accepts 0–9 and A–F (case-insensitive). Optional 0x prefix, underscores, and leading − for negatives are all stripped automatically.
Hex digit reference — A through F mean 10–15
Hexadecimal uses sixteen symbols per place. The first ten are the familiar 0 through 9; the last six (A–F) stand for the decimal values 10–15. Every hex digit also packs exactly one nibble (four binary bits).
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
A
= 10
1010
B
= 11
1011
C
= 12
1100
D
= 13
1101
E
= 14
1110
F
= 15
1111
Number system comparison (0 – 32 and common power-of-2 milestones)
Notice how every fourth decimal value lines up with a clean two-digit binary nibble — and how the same value looks short in hex (FF = 255), medium in decimal (255), and long in binary (11111111). Tap any cell to load that decimal into the Dec → Hex tab.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | |
| 1 | 1 | 1 | |
| 10 | 2 | 2 | |
| 11 | 3 | 3 | |
| 100 | 4 | 4 | |
| 101 | 5 | 5 | |
| 110 | 6 | 6 | |
| 111 | 7 | 7 | |
| 1000 | 10 | 8 | |
| 1001 | 11 | 9 | |
| 1010 | 12 | A | |
| 1011 | 13 | B | |
| 1100 | 14 | C | |
| 1101 | 15 | D | |
| 1110 | 16 | E | |
| 1111 | 17 | F | |
| 10000 | 20 | 10 | |
| 10001 | 21 | 11 | |
| 10010 | 22 | 12 | |
| 10011 | 23 | 13 | |
| 10100 | 24 | 14 | |
| 10101 | 25 | 15 | |
| 10110 | 26 | 16 | |
| 10111 | 27 | 17 | |
| 11000 | 30 | 18 | |
| 11001 | 31 | 19 | |
| 11010 | 32 | 1A | |
| 11011 | 33 | 1B | |
| 11100 | 34 | 1C | |
| 11101 | 35 | 1D | |
| 11110 | 36 | 1E | |
| 11111 | 37 | 1F | |
| 100000 | 40 | 20 | |
| 1000000 | 100 | 40 | |
| 10000000 | 200 | 80 | |
| 11111111 | 377 | FF | |
| 100000000 | 400 | 100 | |
| 10000000000 | 2000 | 400 | |
| 111111111111 | 7777 | FFF | |
| 1000000000000 | 10000 | 1000 | |
| 1111111111111111 | 177777 | FFFF | |
| 10000000000000000 | 200000 | 10000 | |
| 11111111111111111111 | 3777777 | FFFFF | |
| 111111111111111111111111 | 77777777 | FFFFFF |
What Is A Hex Calculator?
A hex calculator performs arithmetic on hexadecimal (base-16) numbers and converts freely between hex, decimal, binary, and octal. The three tools on this page cover the everyday operations a programmer, web developer, embedded engineer, or computer-science student needs: add / subtract / multiply / divide two hex values, decode a hex literal into its decimal equivalent with a full place-value breakdown, and encode a decimal integer back into hex using the repeated-division-by-16 method.
Every result is computed with JavaScript's arbitrary-precision BigIntarithmetic so the answers stay exact even for huge values like DEADBEEFCAFEBABE. Each calculation also returns the same value in binary, octal, scientific notation, and a byte-grouped hex view, so it is straightforward to copy the answer into source code, a memory dump, a CSS colour rule, or a network capture.
Understanding Base-16 Numbers
Sixteen symbols per place
Base-16 needs sixteen digits, so the familiar 0–9 are extended with the letters A–F representing the values 10, 11, 12, 13, 14, and 15. Each place to the left is worth sixteen times more than the place to its right — 1, 16, 256, 4 096, 65 536, and so on.
Every hex digit equals four binary bits
Because 16 = 2⁴, a single hex character holds exactly one nibble — four binary digits. F is 1111, A is 1010, 7 is 0111. This bijection is why hex is the universal short-form for binary data: a 32-bit register collapses from 32 binary characters to just eight hex characters with zero loss of fidelity.
Two hex digits cover one byte
A byte holds 8 bits — 256 distinct values, which is exactly 16 × 16. So one byte fits into two hex characters (00 through FF). This is why memory dumps, byte-oriented protocols, and embedded register definitions are nearly always written hex pair by hex pair.
Case-insensitive but uppercase by convention
A4F, a4f, A4f all parse to the same value. RFC standards, x86 assembly, and most coding guidelines favour uppercase A–F for readability, while lowercase shows up in URLs, CSS, and some Unix tooling. This calculator silently upper-cases every input to keep the output consistent.
6 Ways To Use This Hex Calculator
Add or subtract hex values
Combine memory offsets, sum register flags, or work out the gap between two addresses. The calculator returns both the hex sum and its decimal equivalent so the magnitude is obvious at a glance.
Multiply or divide a hex literal
Scale a hex value, compute a memory block size, or recover a quotient and remainder for buffer allocation. BigInt arithmetic keeps multi-byte answers exact.
Decode a CSS colour or memory address
Drop a hex literal into the Hex → Decimal tab. Get the decimal value, every digit's contribution, the equivalent binary nibble, and the scientific-notation form.
Encode a byte count as hex
Push a decimal integer through the Decimal → Hex tab to see the repeated-division-by-16 table, every remainder, and the bottom-up read that produces the final hex string.
Cross-check by-hand homework
Computer-science and digital-electronics coursework still asks students to convert by hand. The tables here mirror the standard textbook layout exactly, making it easy to verify each manual step.
Plan low-level data layouts
Sum bit-field offsets, calculate struct sizes, or check alignment by adding hex offsets. The byte-grouped output makes nibble-level inspection straightforward.
How Hex Arithmetic Actually Works
Hex addition and subtraction follow exactly the same column-by-column algorithm as decimal, except the carry kicks in at 16 instead of 10. Adding 8 + 9 gives 17 in decimal but 11 in hex — write down the 1, carry the 1. Adding A + 7 gives the decimal value 17 → again 11 in hex. The trick is being comfortable with the A–F digits standing for 10–15; once that habit is in place, the mechanical process is identical.
Multiplication and long division get tedious by hand because each partial product can reach hex values up to F × F = E1 (= 225 in decimal). In practice everyone converts to decimal, multiplies or divides there, and converts the answer back to hex — which is exactly the pipeline the Arithmetic tab uses internally. The step-by-step card shows both representations side-by-side so the algebra and the notation translation are visible at the same time.
Division returns both an integer quotient and a remainder, just like thedivmodoperator in Python or the integer-division instructions in x86 and ARM. The remainder is reported in both hex and decimal so it can be slotted straight into modulo-style code without further conversion.
Conversion Formulas
Hex → Decimal
value = Σ dᵢ × 16ⁱ
Multiply each hex digit by 16 raised to its position from the right (zero-indexed). Sum the products.
Decimal → Hex
remainders bottom-up of n ÷ 16
Repeatedly divide the decimal value by 16. Each remainder is a hex digit. Read the remainders from the last division back to the first.
Hex → Binary
nibble-by-nibble lookup
Replace each hex digit with its four-bit binary nibble: 0→0000, 5→0101, A→1010, F→1111. Concatenate.
Binary → Hex
group bits into 4 from the right
Pad the binary string on the left with zeros to make its length a multiple of four, then translate each nibble to its hex digit.
Hex → Octal
via binary or decimal
There is no clean direct conversion (octal groups bits in threes, hex in fours). Convert to binary or decimal first, then to octal.
Octal → Hex
via binary or decimal
Same idea in reverse — translate the octal value into binary (three bits per digit) or decimal, then to hex.
Two hex digits = 1 byte
00–FF covers 0–255
A byte holds exactly 256 values, which is exactly the range of two hex digits — handy for memory dumps and colour channels.
Hex floating-point literal
0x1.Cp+10 = 1.75 × 2¹⁰
Hex floats (C99 / C++ / Python) use a mantissa in hex and an exponent of 2. Less common, but exact.
Hex vs Binary vs Decimal — Why Choose Hex?
Computers execute binary natively, but binary is a poor format for human reading — one byte is eight characters of 0s and 1s with no clear grouping. Decimal is easy to read but hides the bit boundaries that matter for low-level work (the same decimal digit can straddle multiple binary bits depending on the value). Hexadecimal threads the needle: short like decimal, but every digit lines up cleanly with a four-bit nibble of binary.
Concretely: the 32-bit memory address 2 533 614 256is unwieldy in decimal and a wall of digits in binary (10010111 00111101 01000111 10110000) but a clean eight-character literal in hex (0x973D47B0). Every byte of the address occupies exactly two hex characters, and the boundaries between bytes are obvious. That is why hex is the canonical format in debuggers, hex editors, network packet captures, firmware listings, and instruction-set documentation.
Decimal is still the right format for quantities a person needs to reason about — file sizes in mebibytes, money, scores, percentages. Hex shows up where the bit layout is the meaning — addresses, flags, colour channels, hashes, opcodes. Pick the representation that matches the level of abstraction the reader needs.
Where Hexadecimal Shows Up Every Day
RGB / CSS colour codes
Web colours are stored as #RRGGBB, three pairs of hex digits ranging from 00 (channel off) to FF (channel full-on). #1E90FF is dodger blue, #FF6347 is tomato red. The shorthand #ABC expands to #AABBCC. Designers and developers move fluently between hex colours and the RGB sliders in their image editor.
Memory addresses & registers
Every debugger, disassembler, and embedded toolchain prints memory addresses in hex (0x7FFEE9B0). Hardware registers — CR0, EFLAGS, SP, the I/O memory map — are documented bit-by-bit using hex literals to specify offsets and bit-field masks.
Programming language literals
C / C++ / Java / C# / Go / Rust / Python / JavaScript / Swift all support 0x-prefixed hex literals — 0xFF, 0xCAFEBABE, 0x1A2B3C. Hex literals make bitmask constants (0x0F00) and magic numbers (Java class files start with 0xCAFEBABE) read at a glance.
Networking & MAC addresses
Ethernet MAC addresses are six hex bytes (3C:22:FB:7A:0E:11). IPv6 addresses are written as eight hex groups. Many TCP/IP header fields, ICMP types, and DNS record values are tabulated in hex in the RFCs.
Hashes, UUIDs, and digital signatures
MD5, SHA-1, SHA-256, and Git commit IDs all render their output as hex strings — a SHA-256 digest is exactly 64 hex characters. UUIDs are 32 hex characters grouped 8-4-4-4-12. Storing or transmitting digests in hex avoids binary-encoding issues across protocols.
Error codes & blue-screens
Windows STOP errors (0x0000007E) and HRESULT values (0x80070005), Mac iBoot codes, ARM CPU exceptions, and POSIX errno tables all use hex error codes — usually because the underlying value is a bit-flagged status word where the binary layout encodes the meaning.
Best Practices When Working With Hex
Always tag a hex literal with the 0x prefix in source code. Without it, a reader (or a compiler) has no way to tell whether 1010 means ten-ten in decimal or four-bits in hex — and the two values differ by an order of magnitude. The prefix is two characters of insurance against a class of subtle bugs.
When inspecting raw memory or a binary file, group hex digits into pairs (bytes) or quads (16-bit halfwords). This is what every hex editor, packet sniffer, and debugger does by default. The byte-grouped output line in the Arithmetic tab follows the same convention so the result drops straight into a memory dump without re-formatting.
For signed-integer work, decide up front how many bits the value occupies and use two's complement consistently. An 8-bit signed −1 is 0xFF; a 16-bit signed −1 is 0xFFFF; a 32-bit signed −1 is 0xFFFFFFFF. They all decode as −1, but the bit width is part of the type — confusing the widths is the single most common source of low-level bugs.
Common Hexadecimal Mistakes
- 1
Confusing hex and decimal literals
Without a 0x prefix, the string 100 is decimal one-hundred but in hex it is 256. Always tag literals — and when reading a number off an unfamiliar display, double-check which base it is in before doing arithmetic.
- 2
Reading the A–F digits as their letter values
A is the value 10, not the value 1. F is 15, not 6 or 15-some-position-from-the-end. This trips up almost everyone the first time. Practise with the digit reference grid above until the mapping is automatic.
- 3
Forgetting place-value positions are zero-indexed
The rightmost digit of a hex number is in position 0 (weight 16⁰ = 1), not position 1. Counting from 1 instead of 0 yields an answer sixteen times too large. The place-value table on this page makes the indexing explicit.
- 4
Adding hex columns as if they were decimal
A + 9 in hex is 13 (decimal 19), not the digit string 19. The column rule is: when the column sum reaches 16, write the value minus 16 and carry 1 — exactly analogous to the decimal carry at 10.
- 5
Treating hex case as significant
Hex is case-insensitive. AbC and ABC are the same value. Some checksum systems require uppercase output for canonicalisation, so prefer uppercase whenever the output is going into a hash, a digital signature, or a comparison.
- 6
Mixing up two's complement bit widths
0xFF is −1 as an 8-bit signed value but 255 as a 16-bit unsigned value. Always make the bit width explicit when interpreting a hex pattern as signed; the same bits can mean very different numbers depending on the type.
Worked Hexadecimal Examples
Hex addition
A4F + 2D9 = D28
2639 + 729 = 3368 in decimal — convert back to hex by repeated ÷ 16.
Hex subtraction
1000 − A = FF6
4096 − 10 = 4086. Borrowing crosses the 16⁰ column into the 16¹ column.
Hex multiplication
A4 × 3B = 25CC
164 × 59 = 9676. A two-digit × two-digit hex multiplication generally produces a four-digit answer.
Hex division with remainder
D28 ÷ 14 = A8 R 8
3368 ÷ 20 = 168 r 8 in decimal — 168 → A8 in hex, remainder 8 carries through unchanged.
Hex → decimal place value
7B3 = 7·256 + 11·16 + 3 = 1971
Each column weight is a power of 16 — read right-to-left.
Decimal → hex repeated division
4095 → F, F, F (bottom-up) = FFF
4095 = 16³ − 1, the largest three-digit hex value.
Hex → binary nibble lookup
FACE → 1111 1010 1100 1110
Each hex digit expands to exactly four bits — pure substitution, no arithmetic.
RGB hex colour
#1E90FF = R 30, G 144, B 255
First pair red, second green, third blue. Always 00–FF per channel.
Why Hexadecimal Matters
It is the canonical low-level format
From x86 instruction encoding to ARM exception vectors to RISC-V status registers, the manuals that define how every CPU works are tabulated in hex. Reading and writing hex fluently is a non-negotiable skill for anyone touching the hardware-software boundary.
It bridges binary and human reading
Hex is short enough to read on a single line, but its one-to-one mapping with binary nibbles means no precision is lost. That makes it the right format for any data whose meaning lives at the bit level — flags, masks, opcodes, structured packets.
It is the language of digital design
Every CSS rule, design-token file, and UI mockup specifies colour in hex (or its rgba() decimal alias). Familiarity with the mapping — FF = max channel, 00 = off, 80 = roughly half — is part of the everyday vocabulary of front-end work.
It powers identification across systems
Hashes, UUIDs, container IDs, blockchain transaction IDs, MAC addresses, and IPv6 addresses are all hex strings. Anywhere a system needs a compact, unique identifier that survives round-tripping through ASCII text, hex is the format of choice.
Methodology you can verify
All arithmetic uses JavaScript's BigInt type, so results stay exact at any width — there is no floating-point drift, even on 200-bit values. Conversions go via the standard toString(16), toString(2), and toString(8) primitives, the same bit-level implementations every browser, Node.js, and V8-based runtime uses. Every step in the working cards mirrors the textbook algorithm so the answer can be reproduced by hand. Read more on the methodology and editorial policy pages.
Frequently Asked Questions
Related Calculators
More number-system and math tools that pair naturally with hexadecimal work.
- Binary CalculatorBinary arithmetic, bitwise operations, and base conversions between binary, decimal, octal, and hex.
- Scientific Notation CalculatorConvert to and from scientific, engineering, and E-notation with arithmetic support.
- Scientific CalculatorAdvanced trig, log, exponent, root, factorial, and memory functions.
- Basic CalculatorFour-function arithmetic with memory, history, percent, square root, and full keyboard support.
- Prime Factorization CalculatorPrime factors with a visual factor tree and step-by-step working.
- Rounding CalculatorRound to decimals, significant figures, nearest 5/10/100, or any custom precision.