On 04 May 2019, at 18:49, Richard Hipp <d...@sqlite.org> wrote:

> On 5/4/19, Manuel Rigger <rigger.man...@gmail.com> wrote:

>> Consider the following example:
>>
>> CREATE TABLE t1 (c0, c1 REAL, PRIMARY KEY (c1, c0));
>> INSERT INTO t1(c1) VALUES (0X7ffffffffffffff);;
>> SELECT ALL * FROM t1 WHERE c1 = 5.76460752303423e+17;
>>
>> I would expect the row to be fetched, which is not the case.
>
> But 0x7ffffffffffffff != 5.76460752303423e+17.  Try it:
>
>    SELECT 0x7ffffffffffffff != 5.76460752303423e+17;
>
> You should get back 0.
>
> The rule of thumb is to never expect the == operator to give a
> meaningful answer for floating-point numbers. Only use <, <=, >, and >=.

My floating-point "don't do that" lesson occured in 1965 when trying to compute 
square roots by Newton's method. This was on an Elliott 803B.



-- 
Cheers  --  Tim
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to