From cbba880bd437449490c70dc4c4c00d6aa2930c24 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Mon, 29 Aug 2011 11:41:16 -0400 Subject: [PATCH] fix double comparision of -0 and 0 for v1 indexes SERVER-3682 --- db/key.cpp | 6 +++++- dbtests/btreetests.inl | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/db/key.cpp b/db/key.cpp index 35231752c0c..06936959e6a 100644 --- a/db/key.cpp +++ b/db/key.cpp @@ -602,11 +602,15 @@ namespace mongo { return false; l += 4; r += 4; case cdate: - case cdouble: if( *((unsigned long long *) l) != *((unsigned long long *) r) ) return false; l += 8; r += 8; break; + case cdouble: + if( *((double *) l) != *((double *) r) ) + return false; + l += 8; r += 8; + break; case cstring: { unsigned sz = ((unsigned) *l) + 1; diff --git a/dbtests/btreetests.inl b/dbtests/btreetests.inl index fe1ba902d97..017c54e57c3 100644 --- a/dbtests/btreetests.inl +++ b/dbtests/btreetests.inl @@ -1602,7 +1602,6 @@ class SignedZeroDuplication : public Base { public: void run() { - if ( 0 ) { // SERVER-3682 ASSERT_EQUALS( 0.0, -0.0 ); DBDirectClient c; c.ensureIndex( ns(), BSON( "b" << 1 ), true ); @@ -1610,7 +1609,6 @@ c.insert( ns(), BSON( "b" << 1.0 ) ); c.update( ns(), BSON( "b" << 1.0 ), BSON( "b" << -0.0 ) ); ASSERT_EQUALS( 1U, c.count( ns(), BSON( "b" << 0.0 ) ) ); - } } };