Convert '165.0' to int

Billy Mays 81282ed9a88799d21e77957df2d84bd6514d9af6 at myhashismyemail.com
Fri Jul 22 11:06:16 EDT 2011


On 07/22/2011 10:58 AM, Grant Edwards wrote:
> On 2011-07-22, Billy Mays<81282ed9a88799d21e77957df2d84bd6514d9af6 at myhashismyemail.com>  wrote:
>> Properly formatted means that Python would accept the string as an
>> argument to float() without raising an exception.
>
> Then you can't assume that '.' is the radix character.
>

When you use radix, I assume you mean the grouping separator for large 
numbers, not the base correct?  I have always heard radix used as the 
base (ie base 2) of the number, as in radix sort.

> No, I'm talking about the claim that you should use decmial so that
> you can use rounding when the OP's example showed that rounding was
> not what he wanted.
>

Yes, you are right.  I mistyped what I was thinking.  Let me rephrase:

decimal is needed to preserve the accuracy of the string to `number` 
conversion.

--
Bill



More information about the Python-list mailing list