OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_FLOAT_UTIL_H_ | 5 #ifndef BASE_FLOAT_UTIL_H_ |
6 #define BASE_FLOAT_UTIL_H_ | 6 #define BASE_FLOAT_UTIL_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include <float.h> | 10 #include <float.h> |
11 #include <math.h> | 11 #include <math.h> |
12 | 12 |
13 #if defined(OS_SOLARIS) | |
14 #include <ieeefp.h> | |
15 #endif | |
16 | |
17 namespace base { | 13 namespace base { |
18 | 14 |
19 inline bool IsFinite(const double& number) { | 15 inline bool IsFinite(const double& number) { |
20 #if defined(OS_MACOSX) | 16 #if defined(OS_ANDROID) |
21 // C99 says isfinite() replaced finite(), and iOS does not provide the | 17 // isfinite isn't available on Android: http://b.android.com/34793 |
22 // older call. | 18 return finite(number) != 0; |
| 19 #elif defined(OS_POSIX) |
23 return isfinite(number) != 0; | 20 return isfinite(number) != 0; |
24 #elif defined(OS_POSIX) | |
25 return finite(number) != 0; | |
26 #elif defined(OS_WIN) | 21 #elif defined(OS_WIN) |
27 return _finite(number) != 0; | 22 return _finite(number) != 0; |
28 #endif | 23 #endif |
29 } | 24 } |
30 | 25 |
31 } // namespace base | 26 } // namespace base |
32 | 27 |
33 #endif // BASE_FLOAT_UTIL_H_ | 28 #endif // BASE_FLOAT_UTIL_H_ |
OLD | NEW |