@@ -62,38 +62,37 @@ MATH_FUN_1(lgamma, lgamma)
6262//TODO: factorial, fsum
6363
6464// Functions that return a tuple
65- mp_obj_t mp_math_frexp (mp_obj_t x_obj ){
66- machine_int_t int_exponent = 0 ;
67- mp_float_t significand = frexp (mp_obj_get_float (x_obj ), & int_exponent );
68- mp_obj_t tuple [2 ];
69- tuple [0 ] = mp_obj_new_float (significand );
70- tuple [1 ] = mp_obj_new_int (int_exponent );
71- return mp_obj_new_tuple (2 , tuple );
65+ mp_obj_t mp_math_frexp (mp_obj_t x_obj ) {
66+ int int_exponent = 0 ;
67+ mp_float_t significand = MICROPY_FLOAT_C_FUN ( frexp ) (mp_obj_get_float (x_obj ), & int_exponent );
68+ mp_obj_t tuple [2 ];
69+ tuple [0 ] = mp_obj_new_float (significand );
70+ tuple [1 ] = mp_obj_new_int (int_exponent );
71+ return mp_obj_new_tuple (2 , tuple );
7272}
7373STATIC MP_DEFINE_CONST_FUN_OBJ_1 (mp_math_frexp_obj , mp_math_frexp );
7474
75- mp_obj_t mp_math_modf (mp_obj_t x_obj ){
76- mp_float_t int_part = 0.0 ;
77- mp_float_t fractional_part = modf (mp_obj_get_float (x_obj ), & int_part );
78- mp_obj_t tuple [2 ];
79- tuple [0 ] = mp_obj_new_float (fractional_part );
80- tuple [1 ] = mp_obj_new_float (int_part );
81- return mp_obj_new_tuple (2 , tuple );
75+ mp_obj_t mp_math_modf (mp_obj_t x_obj ) {
76+ mp_float_t int_part = 0.0 ;
77+ mp_float_t fractional_part = MICROPY_FLOAT_C_FUN ( modf ) (mp_obj_get_float (x_obj ), & int_part );
78+ mp_obj_t tuple [2 ];
79+ tuple [0 ] = mp_obj_new_float (fractional_part );
80+ tuple [1 ] = mp_obj_new_float (int_part );
81+ return mp_obj_new_tuple (2 , tuple );
8282}
8383STATIC MP_DEFINE_CONST_FUN_OBJ_1 (mp_math_modf_obj , mp_math_modf );
8484
8585// Angular conversions
86- mp_obj_t mp_math_radians (mp_obj_t x_obj ){
87- return mp_obj_new_float (mp_obj_get_float (x_obj ) * M_PI / 180.0 );
86+ mp_obj_t mp_math_radians (mp_obj_t x_obj ) {
87+ return mp_obj_new_float (mp_obj_get_float (x_obj ) * M_PI / 180.0 );
8888}
8989STATIC MP_DEFINE_CONST_FUN_OBJ_1 (mp_math_radians_obj , mp_math_radians );
9090
91- mp_obj_t mp_math_degrees (mp_obj_t x_obj ){
92- return mp_obj_new_float (mp_obj_get_float (x_obj ) * 180.0 / M_PI );
91+ mp_obj_t mp_math_degrees (mp_obj_t x_obj ) {
92+ return mp_obj_new_float (mp_obj_get_float (x_obj ) * 180.0 / M_PI );
9393}
9494STATIC MP_DEFINE_CONST_FUN_OBJ_1 (mp_math_degrees_obj , mp_math_degrees );
9595
96-
9796STATIC const mp_map_elem_t mp_module_math_globals_table [] = {
9897 { MP_OBJ_NEW_QSTR (MP_QSTR___name__ ), MP_OBJ_NEW_QSTR (MP_QSTR_math ) },
9998 { MP_OBJ_NEW_QSTR (MP_QSTR_e ), (mp_obj_t )& mp_math_e_obj },
0 commit comments