I have the following code:
SN.get_Chars(5)
SN
is a string so this should give the 5th Char. Ok!
Now I have another code but: SN.get_Chars(0x10)
I wonder what 0x10 is? Is it a number? If it's so, then what is it in decimal notation?
So 0x10 is hexadecimal for 16.
In ASCII and in EBCDIC, ETX is code point 0x03, often displayed as ^C). It is often used as a "break" character (Control-C) to interrupt a program or process. In TOPS-20, it was used to gain the system's attention before logging in.
A value of 0x24 indicates it is a class-specific interface descriptor.
0x means the number is hexadecimal, or base 16.
0x10 is 16.
The simple version is 0x is a prefix denoting a hexadecimal number, source.
So the value you're computing is after the prefix, in this case 10.
But that is not the number 10. The most significant bit 1
denotes the hex value while 0
denotes the units.
So the simple math you would do is
0x10
1 * 16 + 0 = 16
Note - you use 16 because hex is base 16.
Another example:
0xF7
15 * 16 + 7 = 247
You can get a list of values by searching for a hex table. For instance in this chart notice F corresponds with 15.
0xNNNN
(not necessarily four digits) represents, in C at least, a hexadecimal (base-16 because 'hex' is 6 and 'dec' is 10 in Latin-derived languages) number, where N
is one of the digits 0
through 9
or A
through F
(or their lower case equivalents, either representing 10 through 15), and there may be 1 or more of those digits in the number. The other way of representing it is NNNN16.
It's very useful in the computer world as a single hex digit represents four bits (binary digits). That's because four bits, each with two possible values, gives you a total of 2 x 2 x 2 x 2
or 16
(24) values. In other words:
_____________________________________bits____________________________________
/ \
+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
| bF | bE | bD | bC | bB | bA | b9 | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 |
+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
\_________________/ \_________________/ \_________________/ \_________________/
Hex digit Hex digit Hex digit Hex digit
A base-X number is a number where each position represents a multiple of a power of X.
In base 10, which we humans are used to, the digits used are 0
through 9
, and the number 730410 is:
In octal, where the digits are 0
through 7
. the number 7548 is:
Octal numbers in C are preceded by the character 0
so 0123
is not 123 but is instead (1 * 64) + (2 * 8) + 3, or 83.
In binary, where the digits are 0
and 1
. the number 10112 is:
In hexadecimal, where the digits are 0
through 9
and A
through F
(which represent the "digits" 10
through 15
). the number 7F2416 is:
Your relatively simple number 0x10
, which is the way C represents 1016, is simply:
As an aside, the different bases of numbers are used for many things.
It's a hex number and is 16 decimal.
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