py/modmath: Add math.tau, math.nan and math.inf constants.

Configurable by the new MICROPY_PY_MATH_CONSTANTS option.
This commit is contained in:
stijn
2019-11-20 13:38:33 +01:00
committed by Damien George
parent e0b8d69827
commit dd6967202a
9 changed files with 79 additions and 0 deletions

View File

@@ -54,6 +54,14 @@ typedef struct _mp_obj_float_t {
const mp_obj_float_t mp_const_float_e_obj = {{&mp_type_float}, (mp_float_t)M_E};
const mp_obj_float_t mp_const_float_pi_obj = {{&mp_type_float}, (mp_float_t)M_PI};
#if MICROPY_PY_MATH_CONSTANTS
#ifndef NAN
#error NAN macro is not defined
#endif
const mp_obj_float_t mp_const_float_tau_obj = {{&mp_type_float}, (mp_float_t)(2.0 * M_PI)};
const mp_obj_float_t mp_const_float_inf_obj = {{&mp_type_float}, (mp_float_t)INFINITY};
const mp_obj_float_t mp_const_float_nan_obj = {{&mp_type_float}, (mp_float_t)NAN};
#endif
#endif