I really don't understand this concept. My book explains this in a confusing fashion.
How exactly does this system work? How does hex 0xff equal 255?
Or oct 011 equal 9??
Printable View
I really don't understand this concept. My book explains this in a confusing fashion.
How exactly does this system work? How does hex 0xff equal 255?
Or oct 011 equal 9??
Hexadecimal is a base 16 number scheme and Octal is a base 8 scheme. Therefore, F in hexadecimal is equal to 15 and 0xFF would be equal to 15 x 16 + 15 = 255. The octal number of 011 would be calculated as 1 * 8 + 1 = 9.
if you had 16 fingers, you would probably count in base 16..
in computers, we do count in base 16, cos it helps. we need some symbols to represent the count, and 0 to 9 do nicely for the first ten, but then what symbols do we use for the remaining six? rather than defining some new symbols, we just use A to F
dont look at them as letters, look at them as symbols that link to a number of something.. put fifteen apples on a table, and then say "there are F apples there"
think about how decimal things break down:
275
is 2 * 10 * 10
+ 7 * 10
+ 5
so the number 7FE is:
7 * 16 * 16 +
F * 16 +
E
remembering that F means "fifteen" and E means fourteen
-its a weird concept to get your head around, but just imagine that you grew up in a world where the base was different. at the moment, you run on base 10, because you have ten fingers, and you learn to count on your fingers. you understand in base 10, because its all there has ever been. so you must translate from base X to base 10.
a bit like you speak english, and when you learn french, you learn the weird way they say things:
"A quelle heure et il?" => "At what hour is he?"
"J'ai deux heures moins le quart" => "I have 2 hours less a quarter"
we say "What time is it?" "It's one forty five"
so you start translating between english and french.. french people think in french, english people think in english. english people speaking french think in english and convert to french. after some years, they think in french too.
normal people think in tens. computers think in 16s. new programmers think in tens and convert to 16s. oldtimers think in 16s :)