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
5260810d
Commit
5260810d
authored
Mar 08, 2014
by
Damien George
Browse files
py: Wrap mpz float functions in MICROPY_ENABLE_FLOAT.
parent
fdf0da54
Changes
3
Hide whitespace changes
Inline
Side-by-side
py/mpz.c
View file @
5260810d
...
...
@@ -1001,8 +1001,9 @@ machine_int_t mpz_as_int(const mpz_t *i) {
return
val
;
}
machine_float_t
mpz_as_float
(
const
mpz_t
*
i
)
{
machine_float_t
val
=
0
;
#if MICROPY_ENABLE_FLOAT
mp_float_t
mpz_as_float
(
const
mpz_t
*
i
)
{
mp_float_t
val
=
0
;
mpz_dig_t
*
d
=
i
->
dig
+
i
->
len
;
while
(
--
d
>=
i
->
dig
)
{
...
...
@@ -1015,6 +1016,7 @@ machine_float_t mpz_as_float(const mpz_t *i) {
return
val
;
}
#endif
uint
mpz_as_str_size
(
const
mpz_t
*
i
,
uint
base
)
{
if
(
base
<
2
||
base
>
32
)
{
...
...
py/mpz.h
View file @
5260810d
...
...
@@ -65,7 +65,9 @@ mpz_t *mpz_div(const mpz_t *lhs, const mpz_t *rhs);
mpz_t
*
mpz_mod
(
const
mpz_t
*
lhs
,
const
mpz_t
*
rhs
);
machine_int_t
mpz_as_int
(
const
mpz_t
*
z
);
machine_float_t
mpz_as_float
(
const
mpz_t
*
z
);
#if MICROPY_ENABLE_FLOAT
mp_float_t
mpz_as_float
(
const
mpz_t
*
z
);
#endif
uint
mpz_as_str_size
(
const
mpz_t
*
z
,
uint
base
);
char
*
mpz_as_str
(
const
mpz_t
*
z
,
uint
base
);
uint
mpz_as_str_inpl
(
const
mpz_t
*
z
,
uint
base
,
char
*
str
);
py/objint_mpz.c
View file @
5260810d
...
...
@@ -60,10 +60,13 @@ mp_obj_t int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
return
MP_OBJ_NULL
;
}
if
(
op
==
RT_BINARY_OP_TRUE_DIVIDE
||
op
==
RT_BINARY_OP_INPLACE_TRUE_DIVIDE
)
{
machine_float_t
flhs
=
mpz_as_float
(
zlhs
);
machine_float_t
frhs
=
mpz_as_float
(
zrhs
);
if
(
0
)
{
#if MICROPY_ENABLE_FLOAT
}
else
if
(
op
==
RT_BINARY_OP_TRUE_DIVIDE
||
op
==
RT_BINARY_OP_INPLACE_TRUE_DIVIDE
)
{
mp_float_t
flhs
=
mpz_as_float
(
zlhs
);
mp_float_t
frhs
=
mpz_as_float
(
zrhs
);
return
mp_obj_new_float
(
flhs
/
frhs
);
#endif
}
else
if
(
op
<=
RT_BINARY_OP_POWER
)
{
mp_obj_int_t
*
res
=
mp_obj_int_new_mpz
();
...
...
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