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.

DecimalBinaryOctalHex
000
111
1022
1133
10044
10155
11066
11177
1000108
1001119
101012A
101113B
110014C
110115D
111016E
111117F
100002010
100012111
100102212
100112313
101002414
101012515
101102616
101112717
110003018
110013119
11010321A
11011331B
11100341C
11101351D
11110361E
11111371F
1000004020
100000010040
1000000020080
11111111377FF
100000000400100
100000000002000400
1111111111117777FFF
1000000000000100001000
1111111111111111177777FFFF
1000000000000000020000010000
111111111111111111113777777FFFFF
11111111111111111111111177777777FFFFFF

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

1

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.

2

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.

3

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.

4

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.

5

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.

6

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. 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. 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. 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. 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. 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. 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

Hexadecimal — usually shortened to hex — is a base-16 number system. Where decimal uses ten symbols (0–9) and binary uses two (0–1), hex needs sixteen, so the letters A, B, C, D, E, and F are pressed into service for the values 10, 11, 12, 13, 14, and 15. Each hex digit packs the same information as exactly four binary bits, which is why hex is the standard short-form for binary data in programming, memory addresses, and machine code.

Base-16 needs sixteen distinct symbols, but standard decimal only supplies ten. Rather than invent six new glyphs, IBM's mid-1960s System/360 documentation reused the next six letters of the alphabet — A=10, B=11, C=12, D=13, E=14, F=15 — and the convention stuck. Hex is case-insensitive (A4F = a4f), though most style guides and assemblers favour uppercase for readability.

Multiply every hex digit by 16 raised to its position from the right (starting at 0) and add the results. For 7B3: the rightmost 3 is in the 16⁰ column (= 3), B (= 11) is in the 16¹ column (= 176), and 7 is in the 16² column (= 1792). Sum: 1792 + 176 + 3 = 1971. The Hex to Decimal tab on this page generates the full breakdown automatically.

Divide the decimal value by 16 and record the remainder. Then divide the quotient by 16 and record that remainder. Keep going until the quotient is zero. Read the remainders from bottom to top — that string of hex digits is your answer. For 4095: 4095 ÷ 16 = 255 r 15 (F), 255 ÷ 16 = 15 r 15 (F), 15 ÷ 16 = 0 r 15 (F). Reading bottom-up gives FFF.

Computers natively speak binary, but a byte (eight bits) written in binary takes eight characters and is easy to misread (10110011). The same byte in hex is just two characters (B3), and the mapping is direct — every hex digit equals exactly four binary bits. Hex therefore stays close to the hardware while being far more compact and human-friendly than raw binary. This is why memory dumps, color codes, MAC addresses, and machine code are nearly always written in hex.

0x is a programming convention that tags a numeric literal as hexadecimal. Without it, C, Python, JavaScript, Java, and most other languages would treat 1010 as the decimal number one thousand and ten; with the prefix, 0x1010 unambiguously means hex (= 4112 in decimal). This calculator strips a leading 0x automatically so you can paste literals straight from source code.

Sixteen — the values 0 through 15. Two hex digits cover 16 × 16 = 256 values, which is exactly one byte. Four hex digits cover 65,536 values — one 16-bit word. Eight hex digits cover roughly 4.3 billion values — one 32-bit integer. This neat power-of-2 alignment is why programmers naturally count storage in pairs of hex digits.

They carry the same information, but hex is shorter, easier to read, and groups cleanly into bytes. Binary is what the hardware actually executes, so it stays the canonical low-level format. In practice, anywhere a human needs to look at raw bit patterns — debugging memory, configuring registers, reading network captures — hex is used because it is roughly four times more compact than binary with no loss of fidelity.

Web colors are written as a hash followed by six hex digits, like #1E90FF. The first two digits set the red channel (00–FF, i.e. 0–255), the middle two set green, and the last two set blue. #FFFFFF is white (all channels at maximum), #000000 is black, and #FF0000 is pure red. The shorthand #ABC expands to #AABBCC. The Hex → Decimal tab on this page is handy for picking apart a color into its individual channel values.

Yes — usually via two's complement encoding, which is what every modern CPU uses for signed integers. In an 8-bit two's complement byte, 0xFF represents −1, 0x80 represents −128, and 0x7F represents +127. This calculator accepts a leading minus sign (−A4) for plain signed hex arithmetic; for two's complement work, convert to the unsigned form using the appropriate bit width before computing.

Because 16 equals 2⁴. A single hex digit can take sixteen distinct values, which is exactly the number of patterns four binary bits can encode. The mapping is fixed and bijective: 0=0000, 5=0101, A=1010, F=1111. That direct one-to-one correspondence is why programmers freely flip between hex and binary when reading bit-level data.

Memory addresses in a debugger (0x7FFEE9B0), CSS color codes (#FF8800), Git commit hashes (a46e1c0), MAC addresses (3C:22:FB:7A:0E:11), Unicode escapes (\u00E9), hash digests (SHA-256 output), error codes on the Windows blue screen (0x00000050), bytecode disassembly, and embedded-system register maps — every one of these is hex. It is the lingua franca of low-level computing.