Convert '165.0' to int

Grant Edwards invalid at invalid.invalid
Fri Jul 22 17:44:08 CEST 2011


On 2011-07-22, Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6 at myhashismyemail.com> wrote:
> 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.

http://en.wikipedia.org/wiki/Radix_point

>> 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.

True.  You shouldn't try to use a float for values not within the
range of a float.

-- 
Grant Edwards               grant.b.edwards        Yow! NANCY!!  Why is
                                  at               everything RED?!
                              gmail.com            



More information about the Python-list mailing list