Floating-point negative zero doesn't match positive zero in the index
---------------------------------------------------------------------

                 Key: CORE-3547
                 URL: http://tracker.firebirdsql.org/browse/CORE-3547
             Project: Firebird Core
          Issue Type: Bug
          Components: Engine
    Affects Versions: 2.1.4, 2.5.0, 2.0.6, 3.0 Initial, 1.5.6, 2.1.3, 2.1.2, 
2.0.5, 2.1.1, 2.0.4, 2.1.0
            Reporter: Dmitry Yemanov


The IEEE representation of single- and double-precision floating point values 
distinguish between positive and negative zeros. When they're compared 
naturally (using compiler generated code), everything is okay. But if they're 
stored in the index, they get compared byte-wise. As a result, searching for 
the negative zero cannot find the positive zero, and vice versa.

Test case:

select count(*) from rdb$relations where rdb$relation_id = 0
-- result = 1

select count(*) from rdb$relations where rdb$relation_id = 0e0
-- result = 1

select count(*) from rdb$relations where rdb$relation_id = (1e0 - 1e0)
-- result = 1

select count(*) from rdb$relations where rdb$relation_id = -0e0
-- result = 0

select count(*) from rdb$relations where rdb$relation_id = -(1e0 - 1e0)
-- result = 0

In dialect 1 it could be reproduced without explicit floating point values:

select count(*) from rdb$relations where rdb$relation_id = (1 - 1)
-- result = 1

select count(*) from rdb$relations where rdb$relation_id = -(1 - 1)
-- result = 0

At the same time:

select count(*) from rdb$database where 0e0 = -0e0
-- result = 1, as no index is involved

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to