Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Float.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 : Float.fw
37 // file : src/Float.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/float.h>
54 
55 
56 #ifdef OLD_FINITE_VALID
57 
58 #if !defined(__sgi) && !defined(__sun) && !defined(__hpux) && !defined(__linux)
59 
61 
62 bool is_valid(float d)
63 {
64  return (d == d); /* !!! */
65 }
66 
67 bool is_finite(float d)
68 {
69  return (d == d) && (is_valid(d-d));
70 }
72 
73 
74 #else // custom definitions.
75 
76 #ifdef __sgi
77 
78 // implementation for SGI IRIX 5.3.
79 #include <fp_class.h>
80 
82 
83 bool is_finite(float d)
84 {
85  switch (fp_class_f(d)) {
86  case FP_POS_NORM:
87  case FP_NEG_NORM:
88  case FP_POS_ZERO:
89  case FP_NEG_ZERO:
90  case FP_POS_DENORM:
91  case FP_NEG_DENORM:
92  return true;
93  case FP_SNAN:
94  case FP_QNAN:
95  case FP_POS_INF:
96  case FP_NEG_INF:
97  return false;
98  }
99  return false; // NOT REACHED
100 }
101 
102 bool is_valid(float d)
103 {
104  switch (fp_class_f(d)) {
105  case FP_POS_NORM:
106  case FP_NEG_NORM:
107  case FP_POS_ZERO:
108  case FP_NEG_ZERO:
109  case FP_POS_INF:
110  case FP_NEG_INF:
111  case FP_POS_DENORM:
112  case FP_NEG_DENORM:
113  return true;
114  case FP_SNAN:
115  case FP_QNAN:
116  return false;
117  }
118  return false; // NOT REACHED
119 }
121 
122 #endif // __sgi
123 
124 #ifdef __hpux
125 
126 // implementation for HP
127 
129 
130 bool is_valid(float f)
131 {
132  return isnanf(f) == 0;
133 }
134 
135 bool is_finite(float f)
136 {
137  switch (fpclassifyf(f)) {
138  case FP_PLUS_NORM:
139  case FP_MINUS_NORM:
140  case FP_PLUS_ZERO:
141  case FP_MINUS_ZERO:
142  case FP_PLUS_DENORM:
143  case FP_MINUS_DENORM:
144  return true;
145  case FP_PLUS_INF:
146  case FP_MINUS_INF:
147  case FP_SNAN:
148  case FP_QNAN:
149  return false;
150  }
151  return false; // NOT REACHED
152 }
154 
155 #endif // __hpux
156 
157 #ifdef __sun
158 
159 // implementation for SUN
160 
161 #ifdef __SVR4
162 #include <ieeefp.h>
163 #endif // __SVR4
164 
165 #ifdef __svr4__
166 #include <ieeefp.h>
167 #endif // __svr4__
168 
169 // implementation for Sun
170 
172 
173 bool is_valid(float f)
174 {
175  return isnanf(f) == 0;
176 }
177 
178 bool is_finite(float f)
179 {
180  return finite(f);
181 }
183 
184 #endif // __sun
185 
186 #ifdef __linux
187 // Implementation for Linux
189 
190 bool is_finite(float f)
191 {
192  return finite(f) != 0;
193 }
194 
195 bool is_valid(float f)
196 {
197  return isnan(f) == 0;
198 }
200 
201 
202 #endif // __linux
203 #endif // custom definitions.
204 #endif // OLD_FINITE_VALID
205 
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