STIR  6.2.0
ieeefp.h
Go to the documentation of this file.
1 //
2 //
3 /*
4  Copyright (C) 2004- 2012, Hammersmith Imanet Ltd
5  This file is part of STIR.
6 
7  SPDX-License-Identifier: Apache-2.0
8 
9  See STIR/LICENSE.txt for details
10 */
11 #ifndef __stir_numerics_ieeefp_H__
12 #define __stir_numerics_ieeefp_H__
13 
26 #include "stir/common.h"
27 
28 #if defined(_MSC_VER)
29 
30 # include <float.h>
31 # define STIR_isnan _isnan
32 # define STIR_finite _finite
33 
34 #else
35 
36 # include <cmath>
37 
38 // attempt to get to find isnan but it might not work on some systems
39 // terrible hack to try and find isnan in std
40 // will only work for gcc
41 # if _GLIBCPP_USE_C99 && !_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC
42 # define STIR_isnan std::isnan
43 # define STIR_finite std::isfinite
44 # else
45 # if defined(HAVE_IEEEFP_H) // this macro might be set (but probably only by configure)
46 # include <ieeefp.h>
47 # define STIR_isnan isnan
48 # define STIR_finite finite
49 # endif
50 # endif
51 
52 #endif
53 
54 #if !defined(STIR_isnan)
55 # if defined(isnan)
56 # define STIR_isnan isnan
57 # else // portable version
58 // according to IEEE rules if x is NaN, then x!=x
59 // so, the following will work even on non-IEEE systems
60 # define STIR_isnan(x) (x) != (x)
61 # endif
62 #endif
63 
64 #if !defined(STIR_finite)
65 # if defined(finite)
66 # define STIR_finite finite
67 # else // portable version
68 // we give up and say all numbers are finite
69 # define STIR_finite(x) true
70 # endif
71 #endif
72 
73 #ifdef DOXYGEN_SKIP // only when running doxygen
74 // doxygen doesn't execute above preprocessor commands, but then doesn't generate documentation
75 // so define something here
76 # define STIR_finite finite
77 # define STIR_isnan isnan
78 #endif
79 
91 #endif
Definition of work-around macros STIR_isnan and STIR_finite for a few non-portable IEEE floating poin...
basic configuration include file