Hex Calculator
Perform hexadecimal arithmetic, convert between hex and decimal, and explore how base‑16 numbers work in programming and electronics.
Hex Arithmetic
Hex to Decimal
Decimal to Hex
Understanding Hexadecimal: Complete Guide with Rules, Examples, and Applications
Hexadecimal (base‑16) represents numbers using digits 0–9 and letters A–F, making binary data concise and readable for humans in computing, electronics, and networking.
This section mirrors the same educational structure as the Exponent page—boxes, subtitles, examples, tables, and practice—so users get a consistent learning experience while working with the Hex Calculator above.
What Is Hexadecimal?
Hexadecimal is a positional number system with base 16. Each position represents a power of 16, from 160 on the right, then 161, 162, and so on.
- Digits: 0–9 and A–F, where A=10, B=11, C=12, D=13, E=14, F=15.
- Place value: Each digit’s value is digit × 16position.
- Binary grouping: One hex digit equals 4 bits, enabling compact binary visualization.
3F16 = 3 × 161 + 15 × 160 = 48 + 15 = 6310.
1A316 = 1 × 256 + 10 × 16 + 3 = 256 + 160 + 3 = 41910.
| Hex | Decimal | Binary (4-bit) | Note |
| 9 | 9 | 1001 | Digit |
| A | 10 | 1010 | Letter digit |
| F | 15 | 1111 | Max single hex |
| 1A | 26 | 0001 1010 | Two digits |
| FF | 255 | 1111 1111 | 8-bit max |
The Seven Essential Rules of Hexadecimal
These rules summarize how to convert and calculate in hex. Mastering them lets you move between hex, decimal, and binary quickly while performing accurate arithmetic.
Multiply each digit’s decimal value by 16 raised to its position and sum the results.
7B16 = 7 × 16 + 11 × 1 = 112 + 11 = 12310.
Divide by 16, collect remainders, and read them from last to first to form the hex number.
15610 → 9C16 (remainders: C then 9).
Each hex digit maps to 4 bits; convert groups of 4 bits to single hex digits and back.
9E16 → 1001 11102.
Add digits right to left; if a column ≥ 16, write remainder and carry 1 to the next column.
1A3 + 2F = 1D216.
Subtract digits; if needed, borrow 1 (which equals 16) from the next column to proceed.
7F − 2B = 5416.
Multiply like decimal long multiplication, but with base 16 and letter digits A–F for 10–15.
1C × 4 = 7016.
Use integer division in base 16 or convert to decimal, divide, and convert back to hex.
F0 ÷ 10 = F16.
| Rule | Method | Example | Result |
| Hex→Dec | Sum of 16-powers | 2F | 47 |
| Dec→Hex | Repeated division | 156 | 9C |
| Hex↔Bin | 4‑bit groups | 9E | 1001 1110 |
| Add | Carry on 16 | 1A3 + 2F | 1D2 |
| Sub | Borrow 1=16 | 7F − 2B | 54 |
Special Hex Topics Explained
Beyond basic conversion and arithmetic, hex appears with signed formats, prefixes, and data widths used throughout programming and digital design.
Hex often displays signed integers stored in two’s complement; interpretation depends on bit width.
FF16 as 8‑bit two’s complement represents −1.
8016 as 8‑bit two’s complement represents −128.
Common hex notations include 0xFF, FFh, and #FF0000 (for colors).
0x3E8 = 100010, #00FF00 is pure green in web colors.
Hex digits may be uppercase or lowercase; values are identical (A=a).
The calculator accepts a–f or A–F and returns uppercase for consistency.
The same hex string can represent different values depending on width and signedness assumptions.
FFFF16 is 65535 unsigned (16‑bit) or −1 as 16‑bit two’s complement.
| Expression | Type | Meaning | Result |
| 0xFF | Unsigned 8‑bit | Max 8‑bit value | 255 |
| 0x80 | Signed 8‑bit | Most negative | −128 |
| 0x7F | Signed 8‑bit | Max positive | 127 |
| 0xFFFF | Unsigned 16‑bit | Max 16‑bit value | 65535 |
| #FF0000 | RGB hex | Red channel max | (255, 0, 0) |
Step-by-Step Calculation Examples
Work through these examples and verify each answer using the Hex Calculator above for instant feedback.
Add 1A3 and 2F in hex.
Step 1: 3 + F = 1810 → 1216, write 2 carry 1
Step 2: A(10) + 2 + 1 = 1310 → D16
Step 3: 1 + 0 = 1
Result: 1D216.
Compute 7F − 2B in hex.
7F → 127, 2B → 43; 127 − 43 = 84; 84 → 5416.
Convert 100010 to hex.
1000 ÷ 16 = 62 r 8; 62 ÷ 16 = 3 r 14 (E); 3 ÷ 16 = 0 r 3 → 3E816.
Convert 4D16 to decimal, add 2510, and convert back to hex.
4D16 = 7710; 77 + 25 = 102; 102 → 6616.
Real-World Applications of Hexadecimal
Hex makes binary data compact and readable, so it appears in software engineering, networking, graphics, and embedded systems.
💾 Memory and Pointers
Debuggers and operating systems display addresses and dumps in hex for clarity (e.g., 0x7FFE1234).
🎨 Web Colors
CSS colors use #RRGGBB; #FF0000 is red, #00FF00 green, #0000FF blue.
🔌 Embedded Systems
Registers and bitmasks are documented in hex, matching hardware bit patterns efficiently.
🌐 Networking
Packet analyzers, checksums, and protocol fields are frequently shown in hex for pattern recognition.
🔐 Cryptography
Hashes like SHA‑256 are often rendered in hex for compact textual representation.
🧰 File Formats
Hex editors show binary files as hex for inspection and patching without decoding to text.
Common Mistakes and How to Avoid Them
Hex errors often come from mixing bases or mishandling carries/borrows; clear notation and methodical steps prevent most mistakes.
Using A–F as “invalid” digits causes failed conversions. ✅ Treat A–F as 10–15.
Switching between decimal and hex mid‑column leads to wrong carries. ✅ Stick to one base per step or convert at boundaries.
Removing zeros while grouping bits can shift nibble alignment. ✅ Group binary in 4‑bit blocks first, then simplify.
Treating two’s complement as unsigned changes meaning. ✅ Decide width/signedness before interpreting.
- Write base subscripts (e.g., 2F16, 4710) during manual work.
- Use 4‑bit groups for hex↔binary conversions.
- Check carries/borrows column by column.
- Verify results in the calculator to build intuition.
- Confirm signedness and bit width before interpreting values.
Nibble Grouping and Large Values
Because hex compresses four bits per digit, it maps neatly to typical CPU widths and helps reason about limits and masks.
Each nibble (4 bits) maps to one hex digit; fixed widths (8, 16, 32, 64 bits) map to 2, 4, 8, 16 hex digits respectively.
Max 8‑bit value is 0xFF = 25510.
0xFFFF = 6553510.
0xFFFFFFFF = 4,294,967,29510 (unsigned).
| Bit width | Max hex | Description |
| 8 | FF | One byte (2 hex digits) |
| 16 | FFFF | Two bytes (4 hex digits) |
| 32 | FFFFFFFF | Four bytes (8 hex digits) |
| 64 | FFFFFFFFFFFFFFFF | Eight bytes (16 hex digits) |
| 128 | …32 hex digits… | Common in crypto hashes |
- Pad binary on the left so length is a multiple of 4.
- Split into 4‑bit groups (nibbles).
- Map each nibble to a hex digit (0000→0, …, 1111→F).
- Join digits; strip extra leading zeros if desired.
Practice Problems with Solutions
Try these problems, then open the solutions to compare your work and verify with the Hex Calculator.
Show Solution
4 × 16 + 13 = 64 + 13 = 77
Show Solution
200 ÷ 16 = 12 r 8 (C, 8); 12 ÷ 16 = 0 r 12 (C) → C8
Show Solution
3A + 7F = B916
Show Solution
1110→E, 0101→5 → E5
Show Solution
FF is −1 in 8‑bit signed representation
Show Solution
1C × 4 = 70; 70 − 2 = 6E