CalcMountain

Hex to Decimal Converter

Convert numbers between hexadecimal (base 16), decimal (base 10), binary (base 2), and octal (base 8). Enter a decimal value to see its representation in all four number bases instantly.

Hexadecimal is the shorthand of computer science. Base-16 packs four binary bits into a single character, so a byte (8 bits) is just two hex digits — 00 to FF, covering 0 to 255 in decimal. That compactness is why hex appears everywhere binary data needs to be readable: HTML color codes (#FF5733), MAC addresses (00:1A:2B:3C:4D:5E), memory addresses (0x7FFE0000), Unicode codepoints (U+1F600), Git commit SHAs (a3f9c2b…), and cryptographic hashes (SHA-256 outputs).

The system uses digits 0–9 plus letters A–F for the values 10–15. Counting in hex goes 0, 1, 2, …, 9, A, B, C, D, E, F, 10 (which is 16 decimal), 11 (17), …, 1F (31), 20 (32), and so on. Each position is a power of 16: the rightmost is 16⁰ = 1, then 16¹ = 16, 16² = 256, 16³ = 4096. Once you internalize that pattern, converting between hex and decimal becomes mechanical, and reading hex dumps stops feeling alien.

This calculator converts between hexadecimal, decimal, binary, and octal in real time. Enter any decimal value and instantly see it in all four bases. Use it for debugging, color picking, file forensics, or whenever you need to translate between how humans count and how machines store.

Inputs

Results

Decimal

255

Hexadecimal

0xFF

Binary

1111 1111

Octal

0o377

Last updated:

Formula

**Hex to decimal:** decimal = Σ (digit_i × 16^i) Where digit_i is the value of the hex digit at position i (counting from the right, starting at 0), and digits A–F represent 10–15. **Example: 0x1A3F → ?** - Position 3: 1 × 16³ = 4096 - Position 2: A (10) × 16² = 2560 - Position 1: 3 × 16¹ = 48 - Position 0: F (15) × 16⁰ = 15 - Total: 4096 + 2560 + 48 + 15 = **6719₁₀** **Decimal to hex (repeated division by 16):** Divide by 16, record the remainder (0–15, written as 0–F), divide the quotient by 16, repeat until quotient is 0. Read remainders bottom-up. **Example: 6719 → ?** - 6719 ÷ 16 = 419 r 15 (F) - 419 ÷ 16 = 26 r 3 - 26 ÷ 16 = 1 r 10 (A) - 1 ÷ 16 = 0 r 1 - Read bottom-up: **0x1A3F** **Hex ↔ binary shortcut (4 bits per digit):** | Hex | Binary | Decimal | |-----|--------|---------| | 0 | 0000 | 0 | | 1 | 0001 | 1 | | 2 | 0010 | 2 | | 3 | 0011 | 3 | | 4 | 0100 | 4 | | 5 | 0101 | 5 | | 6 | 0110 | 6 | | 7 | 0111 | 7 | | 8 | 1000 | 8 | | 9 | 1001 | 9 | | A | 1010 | 10 | | B | 1011 | 11 | | C | 1100 | 12 | | D | 1101 | 13 | | E | 1110 | 14 | | F | 1111 | 15 | **Notation conventions:** 0x prefix (C, JavaScript), # prefix (CSS colors), $ prefix (assembly, classic Mac), trailing h (Intel assembly), or just "hex:" in docs. All mean the same thing.

How to use this calculator

  1. Enter a decimal value in the input. The converter shows the equivalent in hex, binary, and octal.
  2. For a hex color like #FF5733, split into RGB pairs: FF = 255 (red), 57 = 87 (green), 33 = 51 (blue).
  3. For memory addresses, hex is usually written with 0x prefix and may be 8 (32-bit) or 16 (64-bit) digits.
  4. When converting hex → binary by hand, replace each hex digit with its 4-bit equivalent from the table.
  5. For ASCII / Unicode lookup, use the decimal codepoint with a character chart (e.g., 0x41 = 65 = "A").
  6. For Git short SHAs, the first 7 hex chars are usually enough to identify a commit uniquely in most repos.

Worked examples

Decoding a CSS color

**Scenario:** You need to know the exact RGB values behind the brand color #2E86AB. **Calculation:** Split into pairs: 2E (R), 86 (G), AB (B). Convert each: 2E = 2×16 + 14 = 46. 86 = 8×16 + 6 = 134. AB = 10×16 + 11 = 171. So #2E86AB = rgb(46, 134, 171) — a muted teal blue. **Result:** Color #2E86AB is rgb(46, 134, 171). Knowing both forms is useful: hex is compact for CSS, RGB is needed for color math, opacity blending, and most design tool APIs.

Reading a memory address in a debugger

**Scenario:** A crash log shows your program faulted at 0x7FFE000A3C40 when trying to dereference a pointer. **Calculation:** This is a 48-bit address (12 hex digits). The 0x7FFE prefix indicates user-space memory on x86-64 Windows. Each hex digit = 4 bits, so 12 digits = 48 bits = the canonical x86-64 user-mode address space. **Result:** Address 0x7FFE000A3C40 = 140,732,920,201,792 decimal. Knowing the prefix patterns (0x7FFE_xxxx user-mode, 0xFFFF_xxxx kernel) helps diagnose crashes before opening a disassembler.

Setting a Unix file permission mask

**Scenario:** You're writing a script and need to set file permissions to 0o755 (octal). What's the underlying bit pattern? **Calculation:** Each octal digit = 3 bits. 7 = 111, 5 = 101, 5 = 101 → 111 101 101 binary = 0x1ED hex = 493 decimal. The bits represent rwxr-xr-x: owner read/write/execute, group read/execute, others read/execute. **Result:** chmod 755 = 0o755 octal = 0x1ED hex = 493 decimal. Octal is the traditional notation because each octal digit cleanly maps to one rwx triple — historical Unix used octal for this reason.

When to use this calculator

**Hexadecimal shows up whenever you work close to the machine:**

- **Web development:** CSS colors (#RRGGBB or #RRGGBBAA for alpha), Unicode escapes (\u00E9 for "é"), URL encoding (%20 for space). - **Networking:** MAC addresses (six hex pairs), IPv6 addresses (eight 16-bit hex groups), DNS query IDs, TLS cipher suite identifiers. - **Cryptography:** SHA-256 hashes (64 hex chars), AES keys, certificate fingerprints, Bitcoin addresses (Base58 but derived from hex). - **Debugging and forensics:** memory addresses (0x… pointers), hex dumps of files (`xxd`, `hexdump`), assembly opcodes, register values in CPU traces. - **Game development and graphics:** color literals, GPU shader constants, texture format flags, vertex buffer offsets. - **Embedded systems:** I²C/SPI register maps, microcontroller datasheets, firmware addresses, OTP fuses. - **Version control:** Git commit SHAs (40 hex chars, or 7-char short form), object IDs in databases like MongoDB's ObjectId.

**Pattern recognition that helps:** - 0xFF, 0xFFFF, 0xFFFFFFFF = maximum unsigned values at 8, 16, 32 bits. - 0x80, 0x8000, 0x80000000 = the sign bit boundary for signed integers. - 0xDEADBEEF, 0xCAFEBABE, 0xFEEDFACE, 0xC0FFEE = sentinel "magic numbers" used in debugging, class file headers (Java .class starts with 0xCAFEBABE), and uninitialized memory markers. - 0x1F, 0x7F, 0xFF correspond to ASCII control character ranges and the printable boundary.

Common mistakes to avoid

  • Confusing the letter O with the digit 0, or the letter I with the digit 1, when transcribing hex from images or screen captures. Always double-check ambiguous chars.
  • Reading a hex string as decimal (so "10" is read as ten instead of sixteen). Always note the base or prefix explicitly.
  • Forgetting that A-F represent 10-15. New programmers sometimes assume A = 1, B = 2 (since they're "next after 9").
  • Mixing up case: 0xff and 0xFF are the same value. Most style guides prefer uppercase for hex literals, but languages accept both.
  • Endianness confusion when reading multi-byte values from a hex dump. 0x1234 might be stored as bytes 34 12 (little-endian, x86) or 12 34 (big-endian, network byte order).
  • Treating a hex color #FFF as gray instead of white. The 3-digit form #FFF expands to #FFFFFF (each digit doubled).
  • Padding errors: 0xF and 0x0F are the same value (15), but in fixed-width contexts (UUIDs, MAC addresses, color codes) leading zeros are required for correct parsing.

Frequently Asked Questions

Sources & further reading

SponsoredShop Top Deals on AmazonSupport CalcMountain — browse top-rated products at no extra cost to you.

Related Calculators