| 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 | // Py_INFINITY: Value that evaluates to a positive double infinity. |
| 43 | #ifndef Py_INFINITY |
| 44 | # define Py_INFINITY ((double)INFINITY) |
| 45 | #endif |
| 46 | |
| 47 | /* Py_HUGE_VAL should always be the same as Py_INFINITY. But historically |
| 48 | * this was not reliable and Python did not require IEEE floats and C99 |
| 49 | * conformity. Prefer Py_INFINITY for new code. |
| 50 | */ |
| 51 | #ifndef Py_HUGE_VAL |
| 52 | # define Py_HUGE_VAL HUGE_VAL |
| 53 | #endif |
| 54 | |
| 55 | /* Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN). The sign is |
| 56 | * undefined and normally not relevant, but e.g. fixed for float("nan"). |
| 57 | */ |
| 58 | #if !defined(Py_NAN) |
| 59 | # define Py_NAN ((double)NAN) |
| 60 | #endif |
| 61 | |
| 62 | #endif /* Py_PYMATH_H */ |
| 63 | |