MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
float_utils.h
1/*
2 * Copyright 2009 10gen Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19namespace mongo {
20
21inline bool isNaN(double d) {
22 return d != d;
23}
24
25inline bool isInf(double d, int* sign = 0) {
26 volatile double tmp = d;
27
28 if ((tmp == d) && ((tmp - d) != 0.0)) {
29 if (sign) {
30 *sign = (d < 0.0 ? -1 : 1);
31 }
32 return true;
33 }
34
35 if (sign) {
36 *sign = 0;
37 }
38
39 return false;
40}
41}
Utility functions for parsing numbers from strings.
Definition compare_numbers.h:20