4 messages in com.mysql.lists.bugsRe: Queries on doubles are not stable
FromSent OnAttachments
Alan G. Carter30 Nov 2000 14:11 
Sasha Pachev01 Dec 2000 16:49 
Thimble Smith02 Dec 2000 09:59 
Michael Widenius03 Dec 2000 02:35 
Subject:Re: Queries on doubles are not stable
From:Michael Widenius (mon@mysql.com)
Date:12/03/2000 02:35:19 AM
List:com.mysql.lists.bugs

Hi!

"Thimble" == Thimble Smith <ti@mysql.com> writes:

Thimble> On Fri, Dec 01, 2000 at 05:49:45PM -0700, Sasha Pachev wrote:

On Thursday 30 November 2000 15:11, Alan G. Carter wrote:

/usr/local/mysql/bin/mysql -v -u root --password=$1 << EOF use mysql create table test_doubles (datum double);

insert into test_doubles values (0.5); insert into test_doubles values (1.0); insert into test_doubles values (1.5); insert into test_doubles values (2.0); insert into test_doubles values (2.5);

select * from test_doubles; select * from test_doubles where datum < 1.5; select * from test_doubles where datum > 1.5; select * from test_doubles where datum = 1.5; # # What happens with the bug is: # # 1) 5 rows # 2) 5 rows # 3) 0 rows # 4) 1 rows

The problem with double comparisons is that there is always a margin of error.

Thimble> This would explain the problem if it were row 4 which were Thimble> "incorrect". But it doesn't explain rows 2 and 3 being Thimble> wrong.

Thimble> Alan, I'm not aware of any changes between 3.23.25 and the Thimble> current code that pertain to this - nor have I heard of this Thimble> problem in 3.23.25 from anyone else. So, I'm not sure what Thimble> is making the difference....

Alan, did you compiled MySQL 3.23.25 with a different compiler or on a different machine? I am not aware of any problems with floats that could explain 2) in any MySQL version.

Regards, Monty