mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 08:47:28 +01:00
[python] Avoid modifying micropython external source, use parsenum.h methods directly
This commit is contained in:
committed by
LeaNumworks
parent
e76abcf67e
commit
f5e8d4d9bb
@@ -201,24 +201,6 @@ mp_obj_t mp_obj_new_float(mp_float_t value) {
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_new_float_via_str(const char* value) {
|
||||
mp_obj_float_t *o = m_new(mp_obj_float_t, 1);
|
||||
o->base.type = &mp_type_float;
|
||||
//Avoid \x0
|
||||
int length = 0;
|
||||
for(int i = 0; i <= sizeof(value); i++){
|
||||
if(value[i] == '\x0'){
|
||||
length = i;
|
||||
break;
|
||||
}
|
||||
};
|
||||
if(length == 0){
|
||||
length = (int) sizeof(value);
|
||||
}
|
||||
o->value = mp_obj_float_get(mp_parse_num_decimal(value, length, false, false, NULL));
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
mp_float_t mp_obj_float_get(mp_obj_t self_in) {
|
||||
assert(mp_obj_is_float(self_in));
|
||||
mp_obj_float_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
||||
Reference in New Issue
Block a user