Possible Duplicate:
Why are Hexadecimal Prefixed as 0x?
Memory addresses are often notated as a hexidecimal value prefixed with 0x
. E.g:
> new.env()
<environment: 0x21d36e0>
Does the 0x
part mean anything? Where does this notation come from? Is any other value possible instead of 0x
?
0x is hexadecimal (base 16). Without the 0x you get decimal (base 10).
Computers convert binary data into the hexadecimal (hex) number system because it is much less complex than converting data into decimal numbers, and it is much easier for human beings to read hex numbers than to read binary numbers.
The '0x' indicates that the number is in hexadecimal, if it was '0b' then it would in binary.
The prefix 0x is used in code to indicate that the number is being written in hex.
The 0x
is just a notation to let you know the number is in hexadecimal form.
Same as you'd write 042
for an octal number, or 42
for a decimal one.
So - 42 == 052 == 0x2A
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With