create table test(f double);
insert into test values(13.04);
update test set f=f+0.02;
select * from test where f=13.06; -- returns no data

Using MS SQL Server 2000, substituting the "float" type (with a range of -1.79E+308 through 1.79E+308) for your double, I get the same results, i.e. no data returned, because the total ends up being 13.059999999999999 instead of 13.06.

can you imagine how many bugs waiting to happen are out there, because
of code like this ?

Quite a few, for programmers who don't understand the nature of computers and floating point numbers.

however, these are not applicable to people using SQLITE via wrappers
that generate their own UUPDATE code.

pragma floating_accuracy=0.0000001

What about people using MS SQL Server via a wrapper? Should SQL Server, and every other database that exhibts this problem, implement your fix?

Am I the only one that sees the problem? if not, please speak up, and
maybe we can get a neat solution!

I'm not convinced that a wrapper should be hiding this type of thing from the user. It's a part of the underlying DB engine, and the user needs to be aware of it. YMMV.

Reply via email to