What do numbers using 0x notation mean?

Terry Li picture Terry Li · Nov 18, 2011 · Viewed 124.6k times · Source

What does a 0x prefix on a number mean?

const int shared_segment_size = 0x6400;

It's from a C program. I can't recall what it amounts to and particularly what the letter x means.

Answer

Mysticial picture Mysticial · Nov 18, 2011

Literals that start with 0x are hexadecimal integers. (base 16)

The number 0x6400 is 25600.

6 * 16^3 + 4 * 16^2 = 25600

For an example including letters (also used in hexadecimal notation where A = 10, B = 11 ... F = 15)

The number 0x6BF0 is 27632.

6 * 16^3 + 11 * 16^2 + 15 * 16^1 = 27632
24576    + 2816      + 240       = 27632