19

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?

4
  • 4
    0x0000 is a hexadecimal number. The 0x indicates that it should be evaluated in base 16 instead of 10. Without it, you'd not know whether 15 is decimal or hexadecimal (or octal). Is that what you wanted to know? Commented Mar 2, 2012 at 20:28
  • Is there a name for that particular format or I have to type in hexadecimal in google hoping that format will show up?
    – nhat
    Commented Mar 2, 2012 at 20:38
  • 2
    @nhat 0x is a standard hex prefix, it simply tells you the following number will be in hex. A google search shouldnt be necessary(just take what you know about hex and remember that prefix)
    – jzworkman
    Commented Mar 2, 2012 at 20:56
  • Use the Any Base Calculator on the Android market to convert between bases: play.google.com/store/apps/details?id=com.ewe.radixcalculator Commented Apr 1, 2012 at 19:24

5 Answers 5

28

0x simply tells you the number after it will be in hex

so 0x00 is 0, 0x10 is 16, 0x11 is 17 etc

3
  • 1
    @nhat it doesnt go by ones, each place is a factor of 16, so for your case it is 8*16 or 128 because the 8 is in the 16's place.
    – jzworkman
    Commented Mar 2, 2012 at 20:49
  • I noticed 0x00000080 = 0x0080. The formatting what was confusing me but after looking at this more, it starts to make more sense.
    – nhat
    Commented Mar 5, 2012 at 14:56
  • @nhat yea all the leading zero's can be dropped since it is multiplying that power of 16 by zero which doesnt change the result.
    – jzworkman
    Commented Mar 5, 2012 at 18:38
15

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
4
  • cool, thanks for the info. Never saw those formats before. Is there any particular site you learned that from?
    – nhat
    Commented Mar 2, 2012 at 20:40
  • I worked with all those notations before there even was an internet. So, no particular web site. Commented Mar 2, 2012 at 20:43
  • 1
    PHP programmers will identify anything that starts with $ as a variable, not as a hex value.
    – Arjan
    Commented Mar 2, 2012 at 21:36
  • @Arjan: and that's why PHP doesn't use $ for hex notation. Commented Mar 2, 2012 at 21:38
7

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.

5

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).

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.