Everyday Life · Unit Conversions · Digital & Data
Hex to Decimal Converter
Converts a hexadecimal (base-16) number to its decimal (base-10) equivalent using positional notation.
Calculator
Formula
D is the resulting decimal value. Each digit d_i is the decimal value of the hex digit at position i (counting from the right, starting at 0). Hex digits A–F correspond to decimal values 10–15. Each digit is multiplied by 16 raised to the power of its positional index, and all terms are summed.
Source: Knuth, D. E., The Art of Computer Programming, Vol. 2: Seminumerical Algorithms. Positional numeral system arithmetic.
How it works
Decimal (base-10) is the numbering system humans use every day, with digits 0 through 9. Hexadecimal (base-16) extends this by adding the letters A through F to represent the values 10 through 15 as single digits. Because 16 is a power of 2 (2⁴), hexadecimal maps neatly onto binary, making it the preferred shorthand for representing binary data in software development, digital electronics and computer architecture.
Conversion works by treating each hex digit as a coefficient multiplied by the appropriate power of 16. The rightmost digit occupies position 0 (value 16⁰ = 1), the next digit to the left occupies position 1 (value 16¹ = 16), then position 2 (16² = 256), and so on. Each digit's decimal value is multiplied by its positional weight and all products are summed. For example, the hex digit 'C' has decimal value 12, so 'C' in position 2 contributes 12 × 256 = 3072. Hex digits are case-insensitive: 'a' and 'A' both equal 10.
This converter accepts any valid hexadecimal string — including both uppercase and lowercase letters — and returns the exact decimal integer. Practical uses include reading colour codes in CSS (e.g. #FF5733), interpreting memory addresses in debuggers, decoding IP and MAC addresses, understanding file headers and binary data formats, and working with Unicode code points. Learning to read hex fluently is a foundational skill for anyone working close to hardware or low-level software.
Worked example
Let's convert the hexadecimal number 2B9F to decimal step by step.
First, identify each digit and its position (right to left, starting at 0):
- Position 0: F = 15
- Position 1: 9 = 9
- Position 2: B = 11
- Position 3: 2 = 2
Now multiply each digit by 16 raised to its position:
- 15 × 16⁰ = 15 × 1 = 15
- 9 × 16¹ = 9 × 16 = 144
- 11 × 16² = 11 × 256 = 2816
- 2 × 16³ = 2 × 4096 = 8192
Sum all products: 15 + 144 + 2816 + 8192 = 11,167
So hexadecimal 2B9F equals decimal 11,167. You can verify this is correct: 11167 ÷ 16 = 697 remainder 15 (F), 697 ÷ 16 = 43 remainder 9, 43 ÷ 16 = 2 remainder 11 (B), 2 ÷ 16 = 0 remainder 2 — reading remainders bottom to top gives 2B9F.
Limitations & notes
This converter handles standard non-negative integer hexadecimal values. It does not support signed (negative) hex representations such as two's complement notation used in some processor architectures — for example, 0xFFFFFFFF could represent either 4,294,967,295 (unsigned) or −1 (signed 32-bit). It also does not handle hex floating-point notation (e.g. IEEE 754 hex encoding). For very large hexadecimal numbers beyond JavaScript's safe integer range (more than roughly 15–16 hex digits), precision may be lost due to floating-point limitations; a big-integer library would be needed for such values. Input must contain only valid hex digits (0–9, A–F); spaces, '0x' prefixes, or other characters will produce an invalid result.
Frequently asked questions
What are the valid digits in a hexadecimal number?
Hexadecimal uses 16 symbols: the digits 0–9 representing values zero to nine, and the letters A–F (or a–f) representing values 10 through 15. A single hex digit therefore encodes exactly 4 binary bits (a nibble), which is why hex is so convenient for representing binary data compactly.
How do I convert the hex colour code #FF5733 to decimal?
Drop the '#' and split the code into three pairs: FF (red), 57 (green), 33 (blue). Convert each pair independently: FF = 255, 57 = 87, 33 = 51. So #FF5733 represents an RGB colour of (255, 87, 51) — a vivid red-orange. This is standard in CSS, HTML and graphic design tools.
Can I convert negative hexadecimal numbers?
A plain hexadecimal string has no inherent sign. Negative numbers in computing are typically stored as two's complement — for a 32-bit signed integer, 0xFFFFFFFF equals −1, not 4,294,967,295. This converter returns the unsigned decimal value. If you need signed interpretation, you must specify the word size (8, 16, 32, or 64 bits) and apply the two's complement rule separately.
Why is hexadecimal used in computing instead of decimal?
Computers store data in binary (base-2). Hexadecimal is a power-of-two base (16 = 2⁴), so each hex digit maps exactly to 4 binary bits with no rounding or ambiguity. This makes hex a compact, human-readable shorthand for binary: a byte (8 bits) is always exactly two hex digits. Converting between hex and binary is trivial, whereas converting decimal to binary requires repeated division.
What is the largest hexadecimal number this converter can handle accurately?
JavaScript's Number type uses IEEE 754 double-precision floating point, which can represent integers exactly up to 2⁵³ − 1 (9,007,199,254,740,991 in decimal), equivalent to a 13-digit hex number (0x1FFFFFFFFFFFFF). Hex strings longer than about 13–14 digits may lose precision. For cryptographic keys, large memory addresses or 64-bit values, use a dedicated big-integer library or language built-in like Python's built-in int() function.
Last updated: 2025-01-15 · Formula verified against primary sources.