The R Project SVN R

Rev

Rev 7002 | Rev 7016 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7002 Rev 7003
Line 20... Line 20...
20
 
20
 
21
#ifdef HAVE_CONFIG_H
21
#ifdef HAVE_CONFIG_H
22
#include <Rconfig.h>
22
#include <Rconfig.h>
23
#endif
23
#endif
24
 
24
 
25
#include "Defn.h"		/*-> Arith.h */
25
#include "Defn.h"		/*-> R_ext/Arith.h */
26
#include "Mathlib.h"
26
#include "Mathlib.h"
27
#include "Applic.h"		/* machar */
27
#include "Applic.h"		/* machar */
28
#include "arithmetic.h"
28
#include "arithmetic.h"
29
 
29
 
30
/* Error Handling for Floating Point Errors */
30
/* Error Handling for Floating Point Errors */
Line 37... Line 37...
37
    errno = ERANGE;
37
    errno = ERANGE;
38
#ifdef Unix
38
#ifdef Unix
39
    signal(SIGFPE, handle_fperror);
39
    signal(SIGFPE, handle_fperror);
40
#endif
40
#endif
41
}
41
}
42
#endif
42
#endif /* not IEEE_754 */
43
 
43
 
44
#ifdef HAVE_MATHERR
44
#ifdef HAVE_MATHERR
45
 
45
 
46
/* Override the SVID matherr function */
46
/* Override the SVID matherr function */
47
 
47
 
Line 63... Line 63...
63
}
63
}
64
#endif
64
#endif
65
 
65
 
66
#ifdef IEEE_754
66
#ifdef IEEE_754
67
double R_Zero_Hack = 0.0;	/* Silence the Sun compiler */
67
double R_Zero_Hack = 0.0;	/* Silence the Sun compiler */
-
 
68
#ifdef HAVE_IEEE754_H
-
 
69
# include <ieee754.h>		/* newer Linuxen */
-
 
70
#else
-
 
71
# ifdef HAVE_IEEEFP_H
-
 
72
#  include <ieeefp.h>		/* others [Solaris 2.5.x], .. */
-
 
73
# endif
-
 
74
#endif
-
 
75
#if defined(Win32) && defined( _MSC_VER)
-
 
76
#include <float.h>
-
 
77
#endif 
68
 
78
 
69
typedef union
79
typedef union
70
{
80
{
71
  double value;
81
  double value;
72
  unsigned int word[2];
82
  unsigned int word[2];
Line 118... Line 128...
118
	y.value = x;
128
	y.value = x;
119
	return (y.word[lw] != 1954);
129
	return (y.word[lw] != 1954);
120
    }
130
    }
121
    return 0;
131
    return 0;
122
}
132
}
-
 
133
 
-
 
134
int R_IsNaNorNA(double x)
-
 
135
{
-
 
136
    return (isnan(x) != 0);
-
 
137
}
-
 
138
 
-
 
139
int R_finite(double x)
-
 
140
{
-
 
141
#ifndef FINITE_BROKEN
-
 
142
    return finite(x);
-
 
143
# else
-
 
144
#  ifdef _AIX
-
 
145
#   include <fp.h>
-
 
146
     return FINITE(x);
-
 
147
#  else
-
 
148
    return !isnan(x) & (x != R_PosInf) & (x != R_NegInf);
-
 
149
#  endif
123
#endif
150
#endif
-
 
151
}
-
 
152
 
-
 
153
#else /* not IEEE_754 */
-
 
154
 
-
 
155
int R_IsNA(double x)
-
 
156
{
-
 
157
    return (x == R_NaReal);
-
 
158
}
-
 
159
 
-
 
160
int R_IsNaNorNA(double x)
-
 
161
{
-
 
162
# ifndef HAVE_ISNAN
-
 
163
    int finite(double);
-
 
164
    return (x == R_NaReal);
-
 
165
# else
-
 
166
    return (isnan(x) != 0 || x == R_NaReal);
-
 
167
# endif
-
 
168
}
-
 
169
 
-
 
170
int R_finite(double x)
-
 
171
{
-
 
172
# ifndef HAVE_FINITE
-
 
173
    return (x != R_NaReal);
-
 
174
# else
-
 
175
    int finite(double);
-
 
176
    return finite(x);
-
 
177
# endif
-
 
178
}
-
 
179
#endif /* IEEE_754 */
124
 
180
 
125
/* Arithmetic Initialization */
181
/* Arithmetic Initialization */
126
 
182
 
127
void InitArithmetic()
183
void InitArithmetic()
128
{
184
{