Short-circuit Logic

Carlos Nepomuceno carlosnepomuceno at outlook.com
Tue May 28 05:32:20 EDT 2013


----------------------------------------
> Date: Tue, 28 May 2013 01:39:09 -0700
> Subject: Re: Short-circuit Logic
> From: abdulshafy at gmail.com
[...]
>> What Steven wrote is entirely correct: sys.float_info.epsilon is the
>>
>> smallest value x such that 1.0 and 1.0+x have distinct floating-point
>>
>> representations. It has no relevance for comparing to zero.
>
> He just said that the way to test for zero equality is x == 0, and I meant that this is true for integers but not necessarily for floats. And that's not specific to Python.


Have you read [1]? There's a section "Infernal Zero" that discuss this problem. I think it's very interesting to know! ;)

Just my 49.99999999999998¢! lol


[1] http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ 		 	   		  


More information about the Python-list mailing list