Ruby
1.9.3p448(2013-06-27revision41675)
Main Page
Modules
Data Structures
Files
File List
Globals
missing
isinf.c
Go to the documentation of this file.
1
/* public domain rewrite of isinf(3) */
2
3
#ifdef __osf__
4
5
#define _IEEE 1
6
#include <nan.h>
7
8
int
9
isinf
(
double
n)
10
{
11
if
(IsNANorINF(n) && IsINF(n)) {
12
return
1;
13
}
14
else
{
15
return
0;
16
}
17
}
18
19
#else
20
21
#include "ruby/config.h"
22
23
#if defined(HAVE_FINITE) && defined(HAVE_ISNAN)
24
25
#include <math.h>
26
#ifdef HAVE_IEEEFP_H
27
#include <ieeefp.h>
28
#endif
29
30
/*
31
* isinf may be provided only as a macro.
32
* ex. HP-UX, Solaris 10
33
* http://www.gnu.org/software/automake/manual/autoconf/Function-Portability.html
34
*/
35
#ifndef isinf
36
int
37
isinf
(
double
n)
38
{
39
return
(!
finite
(n) && !
isnan
(n));
40
}
41
#endif
42
43
#else
44
45
#ifdef HAVE_STRING_H
46
# include <string.h>
47
#else
48
# include <strings.h>
49
#endif
50
51
static
double
zero
(
void
) {
return
0.0; }
52
static
double
one
(
void
) {
return
1.0; }
53
static
double
inf
(
void
) {
return
one
() /
zero
(); }
54
55
int
56
isinf
(
double
n)
57
{
58
static
double
pinf = 0.0;
59
static
double
ninf = 0.0;
60
61
if
(pinf == 0.0) {
62
pinf =
inf
();
63
ninf = -pinf;
64
}
65
return
memcmp
(&n, &pinf,
sizeof
n) == 0
66
||
memcmp
(&n, &ninf,
sizeof
n) == 0;
67
}
68
#endif
69
#endif
70
Generated on Fri Jun 28 2013 02:34:41 for Ruby by
1.8.3