A funnily inconsistent behavior of int and float

Terry Reedy tjreedy at udel.edu
Mon Apr 7 16:59:21 EDT 2008


"Mark Dickinson" <dickinsm at gmail.com> wrote in message 
news:1255ee3e-cc1e-4ae8-96f3-5f942c389c49 at t54g2000hsg.googlegroups.com...

Thank you for the corrections. Here is my revised proposal:

int([number | string[, radix])
Convert a number or string to an integer.  If no arguments are given,
return 0.  If a number is given, return number.__int__().  Conversion of
 floating point numbers to integers truncates towards zero.  A string must
 be a base-radix integer literal optionally preceded by '+' or '-' (with no
 space in between) and optionally surrounded by whitespace.  A base-n
 literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z')
 having values 10 to 35.  The default radix is 10. The allowed values are 0
 and 2-36.  Base-2, -8, and -16 literals can  be optionally prefixed with 
0b/0B, 0o/0O, or 0x/0X, as with integer literals in code.  Radix 0 means to 
interpret exactly as a code literal, so that the actual radix is 2, 8, 10, 
or 16, and so that int('010',0) is not legal, while int('010') is.

Terry Jan Reedy







More information about the Python-list mailing list