Integer conversion
Derek Thomson
derek at wedgetail.com
Sat Jun 15 09:18:47 EDT 2002
Colin J. Williams wrote:
> int(string, base) => integer
>
> For int('127', 8), I had expected this function to deliver 87.
It does deliver 87. I enter int('127', 8) at the Python prompt, and I
get 87, which is the integer (decimal) value of '127' if interpreted as
a base 8 number.
>
> The example below correctly gives errors at the top and bottom of the
> range and
> for int('127', 10) delivers 127.
Right.
> The other cases are not what I expected.
The output looks correct to me. For example, '127' as a base 16 integer
is 295 (decimal). What output are you seeing, exactly?
Regards,
Derek.
More information about the Python-list
mailing list