2
//===---------------------- support/win32/math_win32.h --------------------===//
4
// The LLVM Compiler Infrastructure
6
// This file is dual licensed under the MIT and the University of Illinois Open
7
// Source Licenses. See LICENSE.TXT for details.
9
//===----------------------------------------------------------------------===//
11
#ifndef _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
12
#define _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
14
#if !defined(_MSC_VER)
15
#error "This header is MSVC specific, Clang and GCC should not include it"
20
typedef float float_t;
21
typedef double double_t;
23
_LIBCPP_ALWAYS_INLINE bool isfinite( double num )
25
return _finite(num) != 0;
27
_LIBCPP_ALWAYS_INLINE bool isinf( double num )
29
return !isfinite(num) && !_isnan(num);
31
_LIBCPP_ALWAYS_INLINE bool isnan( double num )
33
return _isnan(num) != 0;
35
_LIBCPP_ALWAYS_INLINE bool isnormal( double num )
37
int class_ = _fpclass(num);
38
return class_ == _FPCLASS_NN || class_ == _FPCLASS_PN;
41
_LIBCPP_ALWAYS_INLINE bool isgreater( double x, double y )
43
if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
47
_LIBCPP_ALWAYS_INLINE bool isgreaterequal( double x, double y )
49
if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
53
_LIBCPP_ALWAYS_INLINE bool isless( double x, double y )
55
if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
59
_LIBCPP_ALWAYS_INLINE bool islessequal( double x, double y )
61
if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false;
65
_LIBCPP_ALWAYS_INLINE bool islessgreater( double x, double y )
67
if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false;
68
else return x < y || x > y;
71
_LIBCPP_ALWAYS_INLINE bool isunordered( double x, double y )
73
return isnan(x) || isnan(y);
75
_LIBCPP_ALWAYS_INLINE bool signbit( double num )
94
_LIBCPP_ALWAYS_INLINE float copysignf( float x, float y )
96
return (signbit (x) != signbit (y) ? - x : x);
98
_LIBCPP_ALWAYS_INLINE double copysign( double x, double y )
100
return ::_copysign(x,y);
102
_LIBCPP_ALWAYS_INLINE double copysignl( long double x, long double y )
104
return ::_copysignl(x,y);
106
_LIBCPP_ALWAYS_INLINE int fpclassify( double num )
108
return _fpclass(num);
113
#endif // _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H