From c06ea7abf249765bf93595fc42656eed585d7a47 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 21 Mar 2014 10:55:08 +0000 Subject: py: Implement parsing of infinity and nan for floats. --- py/objfloat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'py/objfloat.c') diff --git a/py/objfloat.c b/py/objfloat.c index 401c1145e..65dafa607 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -38,7 +38,7 @@ STATIC mp_obj_t float_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m // a string, parse it uint l; const char *s = mp_obj_str_get_data(args[0], &l); - return mp_parse_num_decimal(s, l); + return mp_parse_num_decimal(s, l, false); } else if (MP_OBJ_IS_TYPE(args[0], &mp_type_float)) { return args[0]; } else { -- cgit v1.2.3 From 6e48f7fa856e4acaf085dfc8876c4e3772d979c2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 21 Mar 2014 11:45:46 +0000 Subject: py: Allow 'complex()' to take a string as first argument. --- py/objfloat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'py/objfloat.c') diff --git a/py/objfloat.c b/py/objfloat.c index 65dafa607..c51e13e7a 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -38,10 +38,12 @@ STATIC mp_obj_t float_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m // a string, parse it uint l; const char *s = mp_obj_str_get_data(args[0], &l); - return mp_parse_num_decimal(s, l, false); + return mp_parse_num_decimal(s, l, false, false); } else if (MP_OBJ_IS_TYPE(args[0], &mp_type_float)) { + // a float, just return it return args[0]; } else { + // something else, try to cast it to a float return mp_obj_new_float(mp_obj_get_float(args[0])); } -- cgit v1.2.3