1 /****************************************************************
2 Copyright 1990 - 1997 by AT&T, Lucent Technologies and Bellcore.
3 
4 Permission to use, copy, modify, and distribute this software
5 and its documentation for any purpose and without fee is hereby
6 granted, provided that the above copyright notice appear in all
7 copies and that both that the copyright notice and this
8 permission notice and warranty disclaimer appear in supporting
9 documentation, and that the names of AT&T, Bell Laboratories,
10 Lucent or Bellcore or any of their entities not be used in
11 advertising or publicity pertaining to distribution of the
12 software without specific, written prior permission.
13 
14 AT&T, Lucent and Bellcore disclaim all warranties with regard to
15 this software, including all implied warranties of
16 merchantability and fitness.  In no event shall AT&T, Lucent or
17 Bellcore be liable for any special, indirect or consequential
18 damages or any damages whatsoever resulting from loss of use,
19 data or profits, whether in an action of contract, negligence or
20 other tortious action, arising out of or in connection with the
21 use or performance of this software.
22 ****************************************************************/
23 
24 #ifndef F2C_ARITH_H
25 #define F2C_ARITH_H
26 
27 #include <f2c_config.h>
28 #include <math.h>
29 
30 #ifdef _MSC_VER
31 #define isnan _isnan
32 #define isinf(x) (!_finite(x))
33 #endif
34 
35 #ifndef isnan
36 # define isnan(x)						 \
37   (sizeof (x) == sizeof (long double) ? isnan_ld (x)		 \
38    : sizeof (x) == sizeof (double) ? isnan_d (x)		 \
39    : isnan_f (x))
isnan_f(float x)40 static inline int isnan_f  (float       x) { return x != x; }
isnan_d(double x)41 static inline int isnan_d  (double      x) { return x != x; }
isnan_ld(long double x)42 static inline int isnan_ld (long double x) { return x != x; }
43 #endif
44 
45 #ifndef isinf
46 # define isinf(x)						 \
47   (sizeof (x) == sizeof (long double) ? isinf_ld (x)		 \
48    : sizeof (x) == sizeof (double) ? isinf_d (x)		 \
49    : isinf_f (x))
isinf_f(float x)50 static inline int isinf_f  (float       x)
51 { return !isnan (x) && isnan (x - x); }
isinf_d(double x)52 static inline int isinf_d  (double      x)
53 { return !isnan (x) && isnan (x - x); }
isinf_ld(long double x)54 static inline int isinf_ld (long double x)
55 { return !isnan (x) && isnan (x - x); }
56 #endif
57 
58 #ifndef signbit
59 #define signbit(x) (((x) < 0)? 1 : 0)
60 #endif
61 
62 #endif
63