binary representaion of a number, debug

Ben Wolfson rumjuggler at cryptarchy.org
Tue Aug 22 23:01:52 EDT 2000


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.

-- 
Barnabas T. Rumjuggler's page of dumbth: members.home.net/rumjuggler

NEW Epistemology Strips!  Dogs don't know they don't know it's not bacon!
 -- Ranjit Bhatnagar



More information about the Python-list mailing list