18 #include "mongo/platform/float_utils.h"
29 return lhs == rhs ? 0 : lhs < rhs ? -1 : 1;
32 inline int compareLongs(
long long lhs,
long long rhs) {
33 return lhs == rhs ? 0 : lhs < rhs ? -1 : 1;
36 inline int compareDoubles(
double lhs,
double rhs) {
46 return isNaN(rhs) ? 0 : -1;
56 inline int compareLongToDouble(
long long lhs,
double rhs) {
63 static const long long kEndOfPreciseDoubles = 1ll << 53;
64 if (lhs <= kEndOfPreciseDoubles && lhs >= -kEndOfPreciseDoubles) {
65 return compareDoubles(lhs, rhs);
69 static const double kBoundOfLongRange = -
static_cast<double>(LLONG_MIN);
70 if (rhs >= kBoundOfLongRange)
72 if (rhs < -kBoundOfLongRange)
78 return compareLongs(lhs, rhs);
81 inline int compareDoubleToLong(
double lhs,
long long rhs) {
83 return -compareLongToDouble(rhs, lhs);
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
int compareInts(int lhs, int rhs)
These functions compare numbers using the same rules as BSON.
Definition: compare_numbers.h:28