[Tutor] If elif not working in comparison
Brian van den Broek
bvande at po-box.mcgill.ca
Tue Mar 29 11:22:19 CEST 2005
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.
>> OK, floats don't necessarily have the exact values you expect (they
>> may have errors after many decimal places), and comparing floats for
>> equality is risky business (you should compare for close, not equal).
>> But the errors are well past the two-digit place. See the FAQ for more
>> info on one kind of error:
>> Note that the original poster was looking at ranges, not looking for
>> exact matches!
>> Can you be more specific about what kinds of problems you have had?
> sure, what is 2/3? 0.66? 0.67?
More information about the Tutor