python (3.11.7)
1 // Symbols and macros to supply platform-independent interfaces to mathematical
2 // functions and constants.
3
4 #ifndef Py_PYMATH_H
5 #define Py_PYMATH_H
6
7 /* High precision definition of pi and e (Euler)
8 * The values are taken from libc6's math.h.
9 */
10 #ifndef Py_MATH_PIl
11 #define Py_MATH_PIl 3.1415926535897932384626433832795029L
12 #endif
13 #ifndef Py_MATH_PI
14 #define Py_MATH_PI 3.14159265358979323846
15 #endif
16
17 #ifndef Py_MATH_El
18 #define Py_MATH_El 2.7182818284590452353602874713526625L
19 #endif
20
21 #ifndef Py_MATH_E
22 #define Py_MATH_E 2.7182818284590452354
23 #endif
24
25 /* Tau (2pi) to 40 digits, taken from tauday.com/tau-digits. */
26 #ifndef Py_MATH_TAU
27 #define Py_MATH_TAU 6.2831853071795864769252867665590057683943L
28 #endif
29
30 // Py_IS_NAN(X)
31 // Return 1 if float or double arg is a NaN, else 0.
32 #define Py_IS_NAN(X) isnan(X)
33
34 // Py_IS_INFINITY(X)
35 // Return 1 if float or double arg is an infinity, else 0.
36 #define Py_IS_INFINITY(X) isinf(X)
37
38 // Py_IS_FINITE(X)
39 // Return 1 if float or double arg is neither infinite nor NAN, else 0.
40 #define Py_IS_FINITE(X) isfinite(X)
41
42 /* HUGE_VAL is supposed to expand to a positive double infinity. Python
43 * uses Py_HUGE_VAL instead because some platforms are broken in this
44 * respect. We used to embed code in pyport.h to try to worm around that,
45 * but different platforms are broken in conflicting ways. If you're on
46 * a platform where HUGE_VAL is defined incorrectly, fiddle your Python
47 * config to #define Py_HUGE_VAL to something that works on your platform.
48 */
49 #ifndef Py_HUGE_VAL
50 # define Py_HUGE_VAL HUGE_VAL
51 #endif
52
53 // Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN).
54 #if !defined(Py_NAN)
55 # if _Py__has_builtin(__builtin_nan)
56 // Built-in implementation of the ISO C99 function nan(): quiet NaN.
57 # define Py_NAN (__builtin_nan(""))
58 #else
59 // Use C99 NAN constant: quiet Not-A-Number.
60 // NAN is a float, Py_NAN is a double: cast to double.
61 # define Py_NAN ((double)NAN)
62 # endif
63 #endif
64
65 #endif /* Py_PYMATH_H */