On Tue, 29 Nov 2005 14:31:46 GMT,
[EMAIL PROTECTED] (Bengt Richter) wrote:
> On Mon, 28 Nov 2005 07:58:37 -0800, [EMAIL PROTECTED] (Alex Martelli) wrote:
>> Python's builtin floats compare for exact bit-by-bit equality -- no
>> "threshold". You may want to look at the allclose function in the
>
Anton81 wrote:
> Hi!
>
> When I do simple calculation with float values, they are rarely exactly
> equal even if they should be. What is the threshold and how can I change
> it?
>
> e.g. "if f1==f2:" will always mean "if abs(f1-f2)<1e-6:"
>
> Anton
googled for "floating point" "comparison toleran
On Mon, 28 Nov 2005 07:58:37 -0800, [EMAIL PROTECTED] (Alex Martelli) wrote:
>Anton81 <[EMAIL PROTECTED]> wrote:
>
>> Hi!
>>
>> When I do simple calculation with float values, they are rarely exactly
>> equal even if they should be. What is the threshold and how can I change
>> it?
>
>Python's bu
On Mon, 28 Nov 2005 12:35:16 -0500, Mike Meyer wrote:
>> e.g. "if f1==f2:" will always mean "if abs(f1-f2)<1e-6:"
>
> This is a *bad* idea. What happens if f1=1e-12 and f2=1e-112? Do you
> really want to values that 100 orders of magnitude different to
> compare as equal?
Sure, if f1 and f2 rep
Anton81 <[EMAIL PROTECTED]> writes:
> When I do simple calculation with float values, they are rarely exactly
> equal even if they should be. What is the threshold and how can I change
> it?
Implementation dependent, because floats use an underlying C type, and
there's no portable way to do that.
"Anton81" wrote:
> When I do simple calculation with float values, they are rarely exactly
> equal even if they should be. What is the threshold
http://www.lahey.com/float.htm
http://docs.python.org/tut/node16.html
> and how can I change it?
you cannot.
> e.g. "if f1==f2:" will always
Anton81 <[EMAIL PROTECTED]> wrote:
> Hi!
>
> When I do simple calculation with float values, they are rarely exactly
> equal even if they should be. What is the threshold and how can I change
> it?
Python's builtin floats compare for exact bit-by-bit equality -- no
"threshold". You may want to
Hi!
When I do simple calculation with float values, they are rarely exactly
equal even if they should be. What is the threshold and how can I change
it?
e.g. "if f1==f2:" will always mean "if abs(f1-f2)<1e-6:"
Anton
--
http://mail.python.org/mailman/listinfo/python-list