From a925639247d4ec90a93262a280f7ef89ca02ccc9 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 20 Mar 2014 16:39:22 +0000 Subject: [PATCH] py: Add math.e constant. --- py/builtinmath.c | 2 ++ py/qstrdefs.h | 1 + 2 files changed, 3 insertions(+) diff --git a/py/builtinmath.c b/py/builtinmath.c index eeb715048a..661638b739 100644 --- a/py/builtinmath.c +++ b/py/builtinmath.c @@ -17,6 +17,7 @@ mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj, mp_obj_t y_obj) { return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj), mp_obj_get_float(y_obj))); } \ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_## py_name ## _obj, mp_math_ ## py_name); +STATIC const mp_obj_float_t mp_math_e_obj = {{&mp_type_float}, M_E}; STATIC const mp_obj_float_t mp_math_pi_obj = {{&mp_type_float}, M_PI}; MATH_FUN_1(sqrt, sqrt) @@ -42,6 +43,7 @@ MATH_FUN_2(atan2, atan2) STATIC const mp_map_elem_t mp_module_math_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_math) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_e), (mp_obj_t)&mp_math_e_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_pi), (mp_obj_t)&mp_math_pi_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_sqrt), (mp_obj_t)&mp_math_sqrt_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_pow), (mp_obj_t)&mp_math_pow_obj }, diff --git a/py/qstrdefs.h b/py/qstrdefs.h index 8f6cc1167f..57ed162f81 100644 --- a/py/qstrdefs.h +++ b/py/qstrdefs.h @@ -119,6 +119,7 @@ Q(module) Q(slice) Q(math) +Q(e) Q(pi) Q(sqrt) Q(pow)