Issue Details (XML | Word | Printable)

Key: CORE-3547
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dmitry Yemanov
Reporter: John Kilin
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird Core

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

Created: 07/Jul/11 03:12 PM   Updated: 09/Apr/14 02:31 PM
Component/s: Engine
Affects Version/s: 2.1.0, 2.0.4, 2.1.1, 2.0.5, 2.1.2, 2.1.3, 1.5.6, 3.0 Initial, 2.0.6, 2.5.0, 2.1.4
Fix Version/s: 2.5.1, 3.0 Alpha 1

Time Tracking:
Not Specified

Issue Links:
Relate
 

Planning Status: Unspecified


 Description  « Hide
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

 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
Firebird #53279 Thu Jul 07 16:24:27 GMT+00:00 2011 dimitr Fixed CORE-3547: Floating-point negative zero doesn't match positive zero in the index.
Files Changed
MODIFY /firebird/branches/B2_5_Release/src/jrd/btr.cpp
MODIFY /firebird/branches/B2_5_Release/src/jrd/sort.cpp

Repository Revision Date User Message
Firebird #53294 Wed Jul 13 15:10:13 GMT+00:00 2011 dimitr Added the missing part for CORE-3547, related to BE platforms.
Cleaned up the unused SKD_d_float.
Files Changed
MODIFY /firebird/branches/B2_5_Release/src/jrd/sort.cpp
MODIFY /firebird/branches/B2_5_Release/src/jrd/sort.h

Repository Revision Date User Message
Firebird #53295 Wed Jul 13 15:15:34 GMT+00:00 2011 dimitr Front ported CORE-3547: Floating-point negative zero doesn't match positive zero in the index.
Files Changed
MODIFY /firebird/trunk/src/jrd/sort.h
MODIFY /firebird/trunk/src/jrd/btr.cpp
MODIFY /firebird/trunk/src/jrd/sort.cpp

Repository Revision Date User Message
Firebird #59410 Wed Apr 09 14:32:53 GMT+00:00 2014 makowski QA-487 for CORE-3547
Files Changed
ADD /qa/fbt-repository/trunk/tests/bugs/core_3547.fbt