Reputation: 1169
I had always been taught 0–9 to represent values zero to nine, and A, B, C, D, E, F for 10-15.
I see this format 0x00000000 and it doesn't fit into the pattern of hexadecimal. Is there a guide or a tutor somewhere that can explain it?
I googled for hexadecimal but I can't find any explanation of it.
So my 2nd question is, is there a name for the 0x00000000 format?
Upvotes: 19
Views: 49599
Reputation: 11838
Yes, it is hexadecimal.
Otherwise, you can't represent A
, for example. The compiler for C and Java will treat it as variable identifier. The added prefix 0x
tells the compiler it's hexadecimal number, so:
int ten_i = 10;
int ten_h = 0xA;
ten_i == ten_h; // this boolean expression is true
The leading zeroes indicate the size: 0x0080
hints the number will be stored in two bytes; and 0x00000080
represents four bytes. Such notation is often used for flags: if a certain bit is set, that feature is enabled.
P.S. As an off-topic note: if the number starts with 0
, then it's interpreted as octal number, for example 010 == 8
. Here 0
is also a prefix.
Upvotes: 7
Reputation: 992707
The 0x
is just a prefix (used in C and many other programming languages) to mean that the following number is in base 16.
Other notations that have been used for hex include:
$ABCD
ABCDh
X'ABCD'
"ABCD"X
Upvotes: 15
Reputation: 1809
Everything after the x are hex digits (the 0x is just a prefix to designate hex), representing 32 bits (if you were to put 0xFFFFFFFF in binary, it would be 1111 1111 1111 1111 1111 1111 1111 1111).
Upvotes: 5
Reputation: 458
hexadecimal digits are often prefaced with 0x to indicate they are hexadecimal digits. In this case, there are 8 digits, each representing 4 bits, so that is 32 bits or a word. I"m guessing you saw this in an error, and it is a memory address. this value means null, as the hex value is 0.
Upvotes: 1
Reputation: 2703
0x simply tells you the number after it will be in hex
so 0x00 is 0, 0x10 is 16, 0x11 is 17 etc
Upvotes: 28