strange math?

Terry Reedy tjreedy at udel.edu
Sun Mar 19 06:38:54 CET 2006


>>>>f(01)
> 43
>>>>f(02)
> 44
>>>>f(010)
> 50
>>>>42+010
> 50

Literal ints with lead 0 are interpreted as octal numbers (base 8) instead 
of decimal numbers (base 10).  01==1 either way, but 010 == 8.
>>> 010
8

0x (zero eks) prefix indicate hexadecimal numbers:
>>> 0xff
255

Terry Jan Reedy






More information about the Python-list mailing list