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.
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
The numbers starting with 0x
are hexadecimal (base 16).0x6400
represents 25600
.
To convert,
The factors 1, 16, 256, etc. are the increasing powers of 16.
0x6400 = (0*1) + (0*16^1) + (4*16^2) + (6*16^3) = 25600
or
0x6400 = (0*1) + (0*16) + (4*256) + (6*4096) = 25600
SIMPLE
It's a prefix to indicate the number is in hexadecimal rather than in some other base. The C programming language uses it to tell compiler.
Example :
0x6400
translates to 6*16^3 + 4*16^2 + 0*16^1 +0*16^0 = 25600.
When compiler reads 0x6400
, It understands the number is hexadecimal with the help of 0x term. Usually we can understand by (6400)16 or (6400)8
or any base ..
Hope Helped in some way.
Good day,
0x prefix C++
brings you here now :) – Carl Smith