Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
96ed2133
Commit
96ed2133
authored
Mar 31, 2014
by
Paul Sokolovsky
Browse files
objfloat: Quick&dirty implementation of float floor division.
TODO: Likely doesn't match Python semantics for negative numbers.
parent
96eec4f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/objfloat.c
View file @
96ed2133
...
...
@@ -111,13 +111,15 @@ mp_obj_t mp_obj_float_binary_op(int op, mp_float_t lhs_val, mp_obj_t rhs_in) {
case
MP_BINARY_OP_INPLACE_SUBTRACT
:
lhs_val
-=
rhs_val
;
break
;
case
MP_BINARY_OP_MULTIPLY
:
case
MP_BINARY_OP_INPLACE_MULTIPLY
:
lhs_val
*=
rhs_val
;
break
;
/
*
TODO
floor(?) the value
/
/
TODO
: verify that C floor matches Python semantics
case
MP_BINARY_OP_FLOOR_DIVIDE
:
case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: val = lhs_val / rhs_val; break;
*/
case
MP_BINARY_OP_INPLACE_FLOOR_DIVIDE
:
lhs_val
=
MICROPY_FLOAT_C_FUN
(
floor
)(
lhs_val
/
rhs_val
);
goto
check_zero_division
;
case
MP_BINARY_OP_TRUE_DIVIDE
:
case
MP_BINARY_OP_INPLACE_TRUE_DIVIDE
:
lhs_val
/=
rhs_val
;
check_zero_division:
if
(
isinf
(
lhs_val
)){
// check for division by zero
nlr_jump
(
mp_obj_new_exception_msg
(
&
mp_type_ZeroDivisionError
,
"float division by zero"
));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment