Skip to main content

Hexadecimal to decimal

By Oakgen Team · Updated

Quick answer

Multiply each hex digit by a power of 16 and add the results. For 1F4: 1×256 + 15×16 + 4×1 = 500.

Hexadecimal to Decimal

Decimal

500
Hex digits and their decimal values
HexDecimal
00
11
22
33
44
55
66
77
88
99
A10
B11
C12
D13
E14
F15

How the method works

Hexadecimal is base 16. It uses the digits 0 to 9 and the letters A to F for ten to fifteen. Each position is worth a power of 16, starting at 1 on the right, then 16, 256, 4,096 and so on.

Take 1F4. The 1 is in the 256s place, F (15) is in the 16s place and 4 is in the ones place: 1×256 + 15×16 + 4 = 500. Take 0x2C: 2×16 + 12 = 44.

Why programmers use hex

One hex digit stands for exactly four bits, so two hex digits describe one byte. NIST's glossary defines a byte as a sequence of eight bits, so its value runs from 0 to 255 (2^8 − 1). RFC 4648 describes Base 16 the same way: two hex characters for each 8-bit octet. That is why a byte is written 00 to FF, and why hex shortens long binary strings without losing any bits.

  • Largest 8-bit value: FF = 255
  • Largest 16-bit value: FFFF = 65535
  • Largest 32-bit value: FFFFFFFF = 4294967295

Common mistakes

A leading 0x only marks the number as hex and is not part of its value. Letters are not case sensitive, so 1f4 and 1F4 are the same number. A letter outside A to F, such as G, means the input is not hexadecimal. Very long hex strings are fine here: the converter uses arbitrary-size integers instead of floating point, so it does not lose digits.

Do more with Oakgen Agent

For a long list of values, the Agent can run the conversion in its code sandbox and hand back a table or a CSV file.

Open in Oakgen Agent

The prompt is filled in for you. Nothing is sent until you press send in the Agent.

FAQ

What is FF in decimal?

FF is 255: 15×16 + 15.

What does the 0x prefix mean?

It tells you the digits that follow are hexadecimal. It is not part of the value, so 0xFF and FF are both 255.

How do I convert a negative hex number?

Convert the digits as normal and put the minus sign in front. Two's-complement values, such as FFFFFFFE as a signed 32-bit number, are a separate interpretation: that one is -2.

Can hex have decimals?

Hex can have a fractional part, using negative powers of 16, but this converter handles whole numbers.

Sources