... LIVE
Enter a whole number from 0 to 4,294,967,295.
Enter any non-negative integer
Hexadecimal (Base 16)

Sources & Methodology

Hexadecimal (base 16) is defined by IEEE and ANSI standards and is fundamental to computer architecture, memory addressing, and digital color systems.
📖
Khan Academy — Hexadecimal Numbers
Educational reference for the decimal to hexadecimal conversion using repeated division by 16
💻
W3Schools — Hexadecimal Colors
Reference for hexadecimal use in HTML/CSS color codes and web design
Method: Repeated division by 16. Remainders 0–9 are written as digits; remainders 10–15 as letters A–F. Read remainders bottom to top.
Nibble display: Each hex digit = 4 binary bits (one nibble).
0x prefix: Standard programming notation indicating a hexadecimal literal.
JavaScript conversion: n.toString(16).toUpperCase() — exact for integers up to 253−1.

⏱ Last reviewed: April 2026

How to Convert Decimal to Hexadecimal

Hexadecimal (base 16) is one of the most important number systems in computing. Unlike binary (base 2) which requires many digits to represent large numbers, hexadecimal provides a compact, human-readable representation. Each hex digit corresponds to exactly four binary bits (a nibble), making it ideal for representing bytes, memory addresses, color codes, and machine instructions.

The Division-by-16 Method

Hex = remainders of (n÷16) read bottom to top, where 10=A, 11=B, 12=C, 13=D, 14=E, 15=F
Example: Convert decimal 255 to hex.
255 ÷ 16 = 15 remainder 15 (F)
15 ÷ 16 = 0 remainder 15 (F)
Read bottom to top: FF
Verify: (15×16) + (15×1) = 240 + 15 = 255 ✓

Hex Digit Reference Table

DecimalHexBinaryDecimalHexBinary
000000881000
110001991001
22001010A1010
33001111B1011
44010012C1100
55010113D1101
66011014E1110
77011115F1111

Common Decimal to Hex Conversions

DecimalHexUse Case
000Null byte, black color #000000
1610First 2-digit hex number
10064Common programming constant (0x64)
1277FSigned 8-bit max, localhost 127.0.0.1
255FFMax byte, white RGB channel, 0xFF
256100First 3-digit hex, 2^8
65535FFFFMax 16-bit value, 0xFFFF
16777215FFFFFFMax 24-bit value, white in #FFFFFF

Hex in Color Codes

HTML and CSS color codes use 6 hex digits in the format #RRGGBB, where RR, GG, and BB are the red, green, and blue channel values in hex (00–FF). White is #FFFFFF (255, 255, 255). Black is #000000 (0, 0, 0). Pure red is #FF0000 (255, 0, 0). Understanding decimal-to-hex conversion is essential for working with color values in web design and graphics programming.

Converting Hex in Programming Languages

💡 Hex-to-binary shortcut: Each hex digit = exactly 4 binary bits. To convert hex FF to binary: F=1111, F=1111 → 11111111. This makes hex a compact shorthand for binary — two hex digits always equal one byte (8 bits).
Frequently Asked Questions
Divide by 16 repeatedly, recording remainders 0–9 as digits and 10–15 as A–F. Read remainders bottom to top. Example: 255 ÷ 16 = 15r15(F), 15 ÷ 16 = 0r15(F) → read bottom to top: FF.
Decimal 255 = hex FF. This is the maximum value of an 8-bit byte, all bits set to 1 (11111111 in binary). FF is used in RGB colors (#FFFFFF = white), subnet masks, and as the null-check byte value in many protocols.
Decimal 10 = hex A. Hexadecimal uses letters A through F to represent values 10 through 15, allowing each single digit to represent 4 binary bits. Decimal 10 = hex A = binary 1010.
Decimal 16 = hex 10. Since 16 is the base of hexadecimal, it works just like decimal 10 in base 10 — the first two-digit number. Hex 10 means (1 × 16) + (0 × 1) = 16.
Use hex(n) for lowercase (hex(255) = '0xff'), or format(n,'X') for uppercase without prefix (format(255,'X') = 'FF'). For zero-padded output: format(255,'02X') = 'FF', format(255,'04X') = '00FF'.
=DEC2HEX(255) returns FF. =DEC2HEX(255,4) returns 00FF (4 characters). Excel's DEC2HEX supports values up to 549,755,813,887. For larger numbers or more control, use Python or JavaScript.
Hexadecimal uses 0–9 and A, B, C, D, E, F. A=10, B=11, C=12, D=13, E=14, F=15. Letters can be uppercase or lowercase (FF = ff). This allows each digit to represent a full nibble (4 bits), making two hex digits equal exactly one byte.
0xFF in decimal is 255. The 0x prefix indicates hexadecimal in programming. FF = (15×16) + (15×1) = 240+15 = 255. 0xFF is the maximum single-byte value and is widely used as a bit mask, max color value, and byte boundary marker.
Each hex digit = exactly 4 binary bits: 0=0000, 1=0001...9=1001, A=1010, B=1011, C=1100, D=1101, E=1110, F=1111. So binary 11111111 = hex FF. Two hex digits always = 8 bits (one byte). This direct correspondence makes hex ideal for representing binary data compactly.
White=#FFFFFF, Black=#000000, Red=#FF0000, Green=#00FF00, Blue=#0000FF, Yellow=#FFFF00, Orange=#FFA500. Each pair of hex digits is one RGB channel from 00 (0 decimal) to FF (255 decimal). Understanding decimal-to-hex lets you read and write color codes directly.
Hex is used in: HTML/CSS colors (#FF5733), memory addresses (0x7FFF4B2A), machine code and assembly, IPv6 (2001:0db8:85a3::1), file magic bytes, Unicode code points (U+1F600), cryptographic hashes (SHA-256 outputs), and any context where binary data needs a compact human-readable form.
Decimal 100 = hex 64. Division: 100÷16=6r4, 6÷16=0r6 → 64. Verify: 6×16+4=100. The constant 0x64 is common in programming for representing the decimal value 100, and 100% in some byte-scaled ranges maps to 0x64.
Hex digits needed = ceiling(log16(n+1)) = ceiling(log(n+1)/log(16)). Examples: 0–15 = 1 digit, 16–255 = 2 digits, 256–4095 = 3 digits, 4096–65535 = 4 digits (common 16-bit), 65536–16777215 = 5–6 digits, 16777216–4294967295 = 7–8 digits (32-bit).
Related Calculators
Popular Calculators
🧮

Missing a Math Calculator?

Can’t find the math calculator you need? Tell us — we build new ones every week.