summaryrefslogtreecommitdiffstatshomepage
path: root/py/objint_longlong.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-04-04 16:45:49 +1000
committerDamien George <damien.p.george@gmail.com>2017-04-04 16:45:49 +1000
commitfc245d1ca4367f9876ac32c7e08e169da7db79b9 (patch)
tree43b5ce6224f13732eb6090cd330ee31c6a14d076 /py/objint_longlong.c
parent3b447ede78970df04e08eeb1cc549a574a733667 (diff)
downloadmicropython-fc245d1ca4367f9876ac32c7e08e169da7db79b9.tar.gz
micropython-fc245d1ca4367f9876ac32c7e08e169da7db79b9.zip
py/objint: Consolidate mp_obj_new_int_from_float to one implementation.
This reduces code duplication and allows to make mp_classify_fp_as_int static, which reduces code size.
Diffstat (limited to 'py/objint_longlong.c')
-rw-r--r--py/objint_longlong.c20
1 files changed, 0 insertions, 20 deletions
diff --git a/py/objint_longlong.c b/py/objint_longlong.c
index 4ab49f337d..540cfebd0a 100644
--- a/py/objint_longlong.c
+++ b/py/objint_longlong.c
@@ -263,26 +263,6 @@ mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) {
return o;
}
-#if MICROPY_PY_BUILTINS_FLOAT
-mp_obj_t mp_obj_new_int_from_float(mp_float_t val) {
- int cl = fpclassify(val);
- if (cl == FP_INFINITE) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OverflowError, "can't convert inf to int"));
- } else if (cl == FP_NAN) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "can't convert NaN to int"));
- } else {
- mp_fp_as_int_class_t icl = mp_classify_fp_as_int(val);
- if (icl == MP_FP_CLASS_FIT_SMALLINT) {
- return MP_OBJ_NEW_SMALL_INT((mp_int_t)val);
- } else if (icl == MP_FP_CLASS_FIT_LONGINT) {
- return mp_obj_new_int_from_ll((long long)val);
- } else {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "float too big"));
- }
- }
-}
-#endif
-
mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) {
// TODO this does not honor the given length of the string, but it all cases it should anyway be null terminated
// TODO check overflow