Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Double.C
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Copyright (c) 1999 The CGAL Consortium
4 
5 // This software and related documentation is part of the Computational
6 // Geometry Algorithms Library (CGAL).
7 // This software and documentation is provided "as-is" and without warranty
8 // of any kind. In no event shall the CGAL Consortium be liable for any
9 // damage of any kind.
10 //
11 // Every use of CGAL requires a license.
12 //
13 // Academic research and teaching license
14 // - For academic research and teaching purposes, permission to use and copy
15 // the software and its documentation is hereby granted free of charge,
16 // provided that it is not a component of a commercial product, and this
17 // notice appears in all copies of the software and related documentation.
18 //
19 // Commercial licenses
20 // - A commercial license is available through Algorithmic Solutions, who also
21 // markets LEDA (http://www.algorithmic-solutions.de).
22 // - Commercial users may apply for an evaluation license by writing to
23 // Algorithmic Solutions (contact@algorithmic-solutions.com).
24 //
25 // The CGAL Consortium consists of Utrecht University (The Netherlands),
26 // ETH Zurich (Switzerland), Free University of Berlin (Germany),
27 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
28 // (Germany), Max-Planck-Institute Saarbrucken (Germany), RISC Linz (Austria),
29 // and Tel-Aviv University (Israel).
30 //
31 // ----------------------------------------------------------------------
32 //
33 // release : CGAL-2.2
34 // release_date : 2000, September 30
35 //
36 // source : Double.fw
37 // file : src/Double.C
38 // package : Number_types (3.4)
39 // revision : 3.4
40 // revision_date : 13 Jul 2000
41 // author(s) : Stefan Schirra
42 // Geert-Jan Giezeman
43 // Sylvain Pion
44 //
45 // coordinator : MPI Informatik, Saarbruecken
46 //
47 // email : contact@cgal.org
48 // www : http://www.cgal.org
49 //
50 // ======================================================================
51 
52 
53 #include <CGAL/double.h>
54 
56 
57 
58 #ifdef CGAL_OLD_FINITE_VALID
59 
60 #if !defined(__sgi) && !defined(__sun) && !defined(__hpux) && !defined(__linux)
61 
62 bool is_valid(double d)
63 {
64  return (d == d); /* !!! */
65 }
66 
67 bool is_finite(double d)
68 {
69  return (d == d) && (CGAL_is_valid(d-d));
70 }
71 
72 #else // custom definitions.
73 
74 #ifdef __sgi
75 
76 // implementation for SGI IRIX 5.3.
77 #include <fp_class.h>
78 
79 bool is_finite(double d)
80 {
81  switch (fp_class_d(d)) {
82  case FP_POS_NORM:
83  case FP_NEG_NORM:
84  case FP_POS_ZERO:
85  case FP_NEG_ZERO:
86  case FP_POS_DENORM:
87  case FP_NEG_DENORM:
88  return true;
89  case FP_SNAN:
90  case FP_QNAN:
91  case FP_POS_INF:
92  case FP_NEG_INF:
93  return false;
94  }
95  return false; // NOT REACHED
96 }
97 
98 bool is_valid(double d)
99 {
100  switch (fp_class_d(d)) {
101  case FP_POS_NORM:
102  case FP_NEG_NORM:
103  case FP_POS_ZERO:
104  case FP_NEG_ZERO:
105  case FP_POS_INF:
106  case FP_NEG_INF:
107  case FP_POS_DENORM:
108  case FP_NEG_DENORM:
109  return true;
110  case FP_SNAN:
111  case FP_QNAN:
112  return false;
113  }
114  return false; // NOT REACHED
115 }
116 
117 #endif // __sgi
118 
119 #ifdef __hpux
120 
121 // implementation for HP
122 
123 bool is_valid(double d)
124 {
125  return isnan(d) == 0;
126 }
127 
128 bool is_finite(double d)
129 {
130  switch (fpclassify(d)) {
131  case FP_PLUS_NORM:
132  case FP_MINUS_NORM:
133  case FP_PLUS_ZERO:
134  case FP_MINUS_ZERO:
135  case FP_PLUS_DENORM:
136  case FP_MINUS_DENORM:
137  return true;
138  case FP_PLUS_INF:
139  case FP_MINUS_INF:
140  case FP_SNAN:
141  case FP_QNAN:
142  return false;
143  }
144  return false; // NOT REACHED
145 }
146 
147 #endif // __hpux
148 
149 #ifdef __sun
150 
151 // implementation for SUN
152 
153 #ifdef __SVR4
154 #include <ieeefp.h>
155 #endif // __SVR4
156 
157 #ifdef __svr4__
158 #include <ieeefp.h>
159 #endif // __svr4__
160 
161 #include <CGAL/config.h>
162 bool is_finite(double d)
163 {
164  if(finite(d)){
165  return true;
166  }
167  return false; // NOT REACHED
168 }
169 
170 bool is_valid(double d)
171 {
172  return isnan(d) == 0;
173 }
174 
175 #endif // __sun
176 
177 #ifdef __linux
178 
179 // Implementation for Linux
180 
181 bool is_finite(double d)
182 {
183  return finite(d) != 0;
184 }
185 
186 bool is_valid(double d)
187 {
188  return isnan(d) == 0;
189 }
190 
191 #endif // __linux
192 #endif // of custom definitions
193 #endif // CGAL_OLD_FINITE_VALID
194 
196 
197 
const NT & d
bool is_finite(double d)
Definition: double.h:190
bool is_valid(double d)
Definition: double.h:185
#define CGAL_BEGIN_NAMESPACE
Definition: kdtree_d.h:86
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87