binary representaion of a number, debug

jepler epler jepler.lnk at lnk.ispi.net
Wed Aug 23 08:29:31 EDT 2000


On Wed, 23 Aug 2000 03:01:52 GMT, Ben Wolfson
 <rumjuggler at cryptarchy.org> wrote:
>On Wed, 23 Aug 2000 02:10:03 GMT, jepler.lnk at lnk.ispi.net (jepler epler)
>wrote:
>
>>	>>> eval('0xffffffff')
>>	-1
>>	>>> int('0xffffffff')
>>	Traceback (innermost last):
>>	  File "<stdin>", line 1, in ?
>>	ValueError: invalid literal for int(): 0xffffffff
>>
>>Why the disparity?
>
>>>> print int.__doc__
>int(x[, base]) -> integer
>
>Convert a string or number to an integer, if possible.  A floating point
>argument will be truncated towards zero (this does not include a string
>representation of a floating point number!)  When converting a string, use
>the optional base.  It is an error to supply a base when converting a
>non-string.
>
>For base 10, 0xffffffff is an invalid literal.

Well, the egg is on my face.  I thought that int(s) was like string.atoi(s, 0)
and I even now think I recal trying strings such as "0x8".

Jeff



More information about the Python-list mailing list