[Tutor] built in functions int(),long()

Magnus Lyckå magnus@thinkware.se
Fri Jun 20 18:42:16 2003


At 22:58 2003-06-19 +0200, kettil wrote:
>How could that be?
>Isn't base "10" named after those ten fingers?(or at least have something 
>to do with 10)
>Or have I missed the point? (have a strong feeling I have)

In a positional number system, like the binary, octal, decimal,
hexadecimal or Mayan, but unlike for instance the roman number
system, you typically have as many digits as the base in your
system, and they have the values 0 to base-1.

The exception I know of is the Mayan system that is base 20 but
actually has 21 digits. (They used digits symbolising 0 to 20,
not 0 to 19. Of course, the digit 20 was only used in the leftmost
position in a number (I assume).)

Anyway, assuming that we use normal arab numbers and if needed
some additional symbols like letters, and use an arbitrary base ?,
we won't be able to write ? as one digit. The highest number we
can write with one digit is ?-1, so ? will always be written as
10, regardless of the base.

In the binary system we have the numbers 0 and 1, so the value
that we call 2 is written 10 in binary. So, if you were a dolphin
with two flippers instead of ten fingers, you would obviously write
that you used base 10, while those human guys with 101 little twigs
on each flipper use base 1010.

Written in it's own system, every positional number system that
uses the kind of notation we do, will call it's own base 10.
*That* is what 10 *really* means. It's the first number that can't
be written with one digit. It's the number that symbolises the
number of different digits in that system.

Or, to put it in Python:

 >>> for i in range(2,17):
...     print int('10', i)
...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16


--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The Agile Programming Language