I understand 2n(9) = 512 but how did it convert to 0x200. Can anyone explain it to me from a different perspective.
Reference problem from "Computer Systems: programmers perspective" Pg.35
I understand 2n(9) = 512 but how did it convert to 0x200. Can anyone explain it to me from a different perspective.
Reference problem from "Computer Systems: programmers perspective" Pg.35
Here is an explanation:
The pattern for using any number base is as follows:
Take the sum of each digit multiplied by the base raised to the power of the offset of the digit from the right.
Deci means "ten"
In school, we were taught that there are ten unique digits. These are:
0, 1, 2, 3, 4, 5, 6, 7, 8 and 9
We use the Arabic Numeral System which says that when we write, 512, what we are saying is this:
( 500 ) + ( 10 ) + ( 2 )
(5 * 10^2) + (1 * 10^1) + (2 * 10^0)
... or ...
five hundreds, one ten, and two ones.
These places are termed things such as, "the ones places," "the tens place," and "the hundreds place."
Hexa means six and deci means ten, so we have six and ten here, or sixteen.
This means that we have 16 unique digits, however the same rules apply as above. We start with the right most digit and move to the left and for each digit we increase the power that the base is raised to and that is the value of that "place." Example:
200 in hexadecimal means:
( 512 ) + ( 0 ) + ( 0 )
(2 * 16^2) + (0 * 16^1) + (0 * 16^0)
In hexadecimal we have the terms, "ones place," "sixteens place," "two hundred and fifty sixths place," "four thousand and ninty sixths place" (mouth full)
As long as there is an agreed upon set of characters for each digit, anyone who knows how to read decimal also knows how to read any other base. You just follow the same pattern: take the sum of each digit multiplied by the base raised to the power of the offset of the digit from the right.
Note: Arabic is written from right to left which might explain why the digits increase from right to left and not left to right, i.e., they seem backwards, if we take the time to really think about it.