mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
fix a bug in appendNumber
This commit is contained in:
parent
1c9e34bcd8
commit
79b8999754
@ -259,14 +259,13 @@ namespace mongo {
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
BSONObjBuilder& appendNumber( const StringData& fieldName , long long l ) {
|
||||
static long long maxInt = (int)pow( 2.0 , 30.0 );
|
||||
static long long maxDouble = (long long)pow( 2.0 , 40.0 );
|
||||
|
||||
if ( l < maxInt )
|
||||
long long x = l >= 0 ? l : -l;
|
||||
if ( x < maxInt )
|
||||
append( fieldName , (int)l );
|
||||
else if ( l < maxDouble )
|
||||
else if ( x < maxDouble )
|
||||
append( fieldName , (double)l );
|
||||
else
|
||||
append( fieldName , l );
|
||||
|
@ -30,7 +30,7 @@ namespace mongo {
|
||||
// takes any of the two forms of strings above. Fundamentally, this class tries
|
||||
// go around the fact that string literals in C++ are char[N]'s.
|
||||
//
|
||||
// Note that the object StringData wraps around must be alive while the StringDAta
|
||||
// Note that the object StringData wraps around must be alive while the StringData
|
||||
// is.
|
||||
|
||||
class StringData {
|
||||
|
Loading…
Reference in New Issue
Block a user