Possible Duplicate:
Why are Hexadecimal Prefixed as 0x?
I just saw a comment a friend of mine made:
3x12=36
2x12=24
1x12=12
0x12=18
Which made me wonder..
Why did they choose 0x
as prefix for hexadecimal numbers? Is there any history behind this decision?
I think, because x
comes from hex
and 0
is to indicate that it is a number.
0x
means the number is probably hexadecimal. This applies in C/C++, and probalby other
languages.
His comment is a joke. he starts with multiplication tables for the number 12, but when he gets to 0 he implies that 0x
is not "0 multiplied by...", but instead is "hexadecimal" so 12 in hex is 18 in decimal.
It's a joke on HEX numbers from WIKIPEDIA.
The first three are interpreted as
multiplication, but in the last, "0x"
signals Hexadecimal interpretation of
12, which is 18.
'0x' means that the number that follows is in hexadecimal. It's a way of unambiguously stating that a number is in hex, and is a notation recognised by C compilers and some assemblers