List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:February 10 2002 5:39pm
Subject:Suggestion re: floating point comparison (was Re: Problem with
where clause)
View as plain text  
Hi!

>>>>> "Steve" == Steve Edberg <sbedberg@stripped> writes:

Steve> ...perhaps a NEAR function could be added; as a config file or compile-time 
Steve> option, you could define an accuracy range. Say,

Steve>          ./config --with-epsilon=0.0001

Steve> (if memory of my numerical analysis classes serves, the 'fudge factor' was 
Steve> conventionally symbolized by epsilon; I suppose you could make it 
Steve> --with-fudge, but this ain't no bakery) so that

Steve>          select 1.0 near 1.00009 => 1
Steve> and
Steve>          select 1.0 near 0.9995 => 0

Steve> The default would be current behavior (epsilon=0).

Steve> This would avoid statements like

Steve>          select * where x > 0.99999999 and x < 1.00000001

Steve> ...just my too sense -

Steve>          -steve

First a note;  We can't generally have a fudge factor for floating
point values.

The problem with this is that if you do 3 selects:

SELECT * from x where < 1
SELECT * from x where == 1
SELECT * from x where > 1

you would get some of the records in all of the above 3 sets.

This could easily in the long run cause even more confusion than the
current scenario.

But a near function/operator would probably be a good idea;  We will
put this on our todo.

Regards,
Monty
Thread