30#include "mongo/platform/float_utils.h"
41 return lhs == rhs ? 0 : lhs < rhs ? -1 : 1;
44inline int compareLongs(
long long lhs,
long long rhs) {
45 return lhs == rhs ? 0 : lhs < rhs ? -1 : 1;
48inline int compareDoubles(
double lhs,
double rhs) {
58 return isNaN(rhs) ? 0 : -1;
68inline int compareLongToDouble(
long long lhs,
double rhs) {
75 static const long long kEndOfPreciseDoubles = 1ll << 53;
76 if (lhs <= kEndOfPreciseDoubles && lhs >= -kEndOfPreciseDoubles) {
77 return compareDoubles(lhs, rhs);
81 static const double kBoundOfLongRange = -
static_cast<double>(LLONG_MIN);
82 if (rhs >= kBoundOfLongRange)
84 if (rhs < -kBoundOfLongRange)
90 return compareLongs(lhs, rhs);
93inline int compareDoubleToLong(
double lhs,
long long rhs) {
95 return -compareLongToDouble(rhs, lhs);
Utility functions for parsing numbers from strings.
Definition compare_numbers.h:32
int compareInts(int lhs, int rhs)
These functions compare numbers using the same rules as BSON.
Definition compare_numbers.h:40