[Tutor] Hex to Str - still an open issue

Brian van den Broek bvande at po-box.mcgill.ca
Thu Feb 10 09:34:42 CET 2005


Johan Geldenhuys said unto the world upon 2005-02-10 00:43:
> I am not so clued up on the 'base 2' and 'base 8' stuff.
> Care to explain that a little?
> 
> Johan
> On Tue, 2005-02-08 at 12:12, Pierre Barbier de Reuille wrote:

<SNIP much quoting of thread on bases among other things>

Hi Johan,

here's a go:

We have 10 fingers. Not coincidentally, we have a base 10 number 
system. OK, what's that mean?

Well, we have 10 primitive numerical symbols {0,1,2,3,4,5,6,7,8,9}. 
So, say we have 7 widgets and then we get another. No problem -- 8 
widgets. Another -- 9. One more? Well, we are out of primitive 
symbols. 9 means nine units. If we add another to 9, we end up with 
one tens and zero units: 10. Each additional place gives us a new 
multiple of 10. So 10342 is one ten-thousands, zero thousands, three 
hundreds, four tens and two units.

And, you might be thinking `Jeeze! I know all that.' Fair enough. 
Here's the switch:

Say we had a number system with only 8 numerical primitives: 
{0,1,2,3,4,5,6,7). That is a base 8 system. (It isn't really the 
reason, but you can think of `base' as "how many primitive symbols is 
the number system based upon" and not be too far off.) If we have 
seven widgets, that's 7 as before. Add one. Well, there is no '8' 
symbol. So, 7 + 1 is one eights and zero units or 10 (010 in Pythonic 
notation but put that aside for now). Twenty four is 30 in base 8 -- 3 
eights and zero units. Likewise base 8 763 is 7 sixtyfours + 6 eights 
+ 3 units or 499 in base 10 or decimal notation.

Base 2 is where we have just the two primitive symbols 0 and 1. So,
11010 in binary notation is one sixteens+ one eights + zero fours + 
one twos + zero units or 26 in decimal. Likewise 14 is one eights and 
one fours and one twos and zero units or 1110.

The general principle is in a base X number system, you have only X 
primitives. To represent more than X - 1 things ('0' being one of the 
primitives) you move a place to the left, and consider the symbols in 
that place as representing X times as many things as the previous place.

I hope I've shed more light than shadows :-)

Best,

brian vdB


More information about the Tutor mailing list