Short-circuit Logic
Ahmed Abdulshafy
abdulshafy at gmail.com
Wed May 29 10:27:40 EDT 2013
On Tuesday, May 28, 2013 3:48:17 PM UTC+2, Steven D'Aprano wrote:
> On Mon, 27 May 2013 13:11:28 -0700, Ahmed Abdulshafy wrote:
>
>
>
> > That may be true for integers, but for floats, testing for equality is
>
> > not always precise
>
>
>
> Incorrect. Testing for equality is always precise, and exact. The problem
>
> is not the *equality test*, but that you don't always have the number
>
> that you think you have. The problem lies elsewhere, not equality!
>
>
> Steven
Well, this is taken from my python shell>
>>> 0.33455857352426283 == 0.33455857352426282
True
Anyway, man, those were not my words anyway, most programming books I've read state so. Here's an excerpt from the Python book, I'm currently reading>
">>> 0.0, 5.4, -2.5, 8.9e-4
(0.0, 5.4000000000000004, -2.5, 0.00088999999999999995)
The inexactness is not a problem specific to Python—all programming languages have this problem with floating-point numbers."
More information about the Python-list
mailing list