~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to missing/isinf.c

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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(n)
 
10
    double n;
 
11
{
 
12
    if (IsNANorINF(n) && IsINF(n)) {
 
13
        return 1;
 
14
    }
 
15
    else {
 
16
        return 0;
 
17
    }
 
18
}
 
19
 
 
20
#else
 
21
 
 
22
#include "config.h"
 
23
 
 
24
#if defined(HAVE_FINITE) && defined(HAVE_ISNAN)
 
25
 
 
26
#include <math.h>
 
27
#ifdef HAVE_IEEEFP_H
 
28
#include <ieeefp.h>
 
29
#endif
 
30
 
 
31
int
 
32
isinf(n)
 
33
    double n;
 
34
{
 
35
    return (!finite(n) && !isnan(n));
 
36
}
 
37
 
 
38
#else
 
39
 
 
40
#ifdef HAVE_STRING_H
 
41
# include <string.h>
 
42
#else
 
43
# include <strings.h>
 
44
#endif
 
45
 
 
46
static double zero()    { return 0.0; }
 
47
static double one()     { return 1.0; }
 
48
static double inf()     { return one() / zero(); }
 
49
 
 
50
int
 
51
isinf(n)
 
52
    double n;
 
53
{
 
54
    static double pinf = 0.0;
 
55
    static double ninf = 0.0;
 
56
 
 
57
    if (pinf == 0.0) {
 
58
        pinf = inf();
 
59
        ninf = -pinf;
 
60
    }
 
61
    return memcmp(&n, &pinf, sizeof n) == 0
 
62
        || memcmp(&n, &ninf, sizeof n) == 0;
 
63
}
 
64
#endif
 
65
#endif