Brian van den Broek wrote:
> Sean Perry said unto the world upon 2005-03-29 03:48:
> 
>> Kent Johnson wrote:
>>
>>>> Not without using round. Have *NO* faith in floating points. This 
>>>> is
>>>> especially true when you are creating the decimals via division and

>>>> the like.
>>>
>>> Can you be more specific about what kinds of problems you have had?
>>>
>>
>> sure, what is 2/3? 0.66? 0.67?
> 
> 
>  >>> 2/3
> 0
>  >>> 2.0/3
> 0.66666666666666663

I don't know what you are getting at here.  The first result is
deterministic because it's integer divison and has nothing to do with
any imprecision in floating points.  Moreover, the original poster was
asking about using two-decimal places for testing which is completely
deterministic in this case as well

>>> 2.0/3 < .66
False
>>> 2.0/3 < .67
True
>>> 

Which is just what you'd expect.

It's absolutey absurd to tell someone to have *NO* faith in floating
numbers.  It's like anything else in programming: you have to understand
what you are doing.

Jeff
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to