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
cd8b2baf
Commit
cd8b2baf
authored
Mar 19, 2014
by
Damien George
Browse files
py: Fix bug in mpz int, where small int is on lhs, mpz on rhs.
parent
494600bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/objint_mpz.c
View file @
cd8b2baf
...
...
@@ -44,11 +44,22 @@ mp_obj_t int_unary_op(int op, mp_obj_t o_in) {
}
mp_obj_t
int_binary_op
(
int
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
mpz_t
*
zlhs
=
&
((
mp_obj_int_t
*
)
lhs_in
)
->
mpz
;
const
mpz_t
*
zlhs
;
const
mpz_t
*
zrhs
;
mpz_t
z_int
;
mpz_dig_t
z_int_dig
[
MPZ_NUM_DIG_FOR_INT
];
// lhs could be a small int (eg small-int + mpz)
if
(
MP_OBJ_IS_SMALL_INT
(
lhs_in
))
{
mpz_init_fixed_from_int
(
&
z_int
,
z_int_dig
,
MPZ_NUM_DIG_FOR_INT
,
MP_OBJ_SMALL_INT_VALUE
(
lhs_in
));
zlhs
=
&
z_int
;
}
else
if
(
MP_OBJ_IS_TYPE
(
lhs_in
,
&
int_type
))
{
zlhs
=
&
((
mp_obj_int_t
*
)
lhs_in
)
->
mpz
;
}
else
{
return
MP_OBJ_NULL
;
}
// if rhs is small int, then lhs was not (otherwise rt_binary_op handles it)
if
(
MP_OBJ_IS_SMALL_INT
(
rhs_in
))
{
mpz_init_fixed_from_int
(
&
z_int
,
z_int_dig
,
MPZ_NUM_DIG_FOR_INT
,
MP_OBJ_SMALL_INT_VALUE
(
rhs_in
));
zrhs
=
&
z_int
;
...
...
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