Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
aca14126
Commit
aca14126
authored
Feb 24, 2014
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Fix mpn_sub, was increasing wrong source pointer.
Also change int -> machine_int_t where appropriate.
parent
2ee55c31
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/mpz.c
+7
-7
7 additions, 7 deletions
py/mpz.c
py/mpz.h
+3
-3
3 additions, 3 deletions
py/mpz.h
with
10 additions
and
10 deletions
py/mpz.c
+
7
−
7
View file @
aca14126
...
...
@@ -113,7 +113,7 @@ uint mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, uint jlen, const mpz_dig_t
borrow
>>=
DIG_SIZE
;
}
for
(;
jlen
>
0
;
--
jlen
,
++
idig
,
++
k
dig
)
{
for
(;
jlen
>
0
;
--
jlen
,
++
idig
,
++
j
dig
)
{
borrow
+=
*
jdig
;
*
idig
=
borrow
&
DIG_MASK
;
borrow
>>=
DIG_SIZE
;
...
...
@@ -315,7 +315,7 @@ void mpn_div(mpz_dig_t *num_dig, machine_uint_t *num_len, mpz_dig_t *den_dig, ma
#define MIN_ALLOC (4)
#define ALIGN_ALLOC (2)
#define NUM_DIG_FOR_INT (sizeof(
in
t) * 8 / DIG_SIZE + 1)
#define NUM_DIG_FOR_INT (sizeof(
machine_int_
t) * 8 / DIG_SIZE + 1)
static
const
uint
log_base2_floor
[]
=
{
0
,
...
...
@@ -329,7 +329,7 @@ static const uint log_base2_floor[] = {
4
,
4
,
4
,
5
};
bool
mpz_int_is_sml_int
(
in
t
i
)
{
bool
mpz_int_is_sml_int
(
machine_int_
t
i
)
{
return
-
(
1
<<
DIG_SIZE
)
<
i
&&
i
<
(
1
<<
DIG_SIZE
);
}
...
...
@@ -497,7 +497,7 @@ int mpz_cmp(const mpz_t *z1, const mpz_t *z2) {
return
cmp
;
}
int
mpz_cmp_sml_int
(
const
mpz_t
*
z
,
in
t
sml_int
)
{
int
mpz_cmp_sml_int
(
const
mpz_t
*
z
,
machine_int_
t
sml_int
)
{
int
cmp
;
if
(
z
->
neg
==
0
)
{
if
(
sml_int
<
0
)
return
1
;
...
...
@@ -885,13 +885,13 @@ mpz_t *mpz_mod(const mpz_t *lhs, const mpz_t *rhs) {
}
#endif
in
t
mpz_as_int
(
const
mpz_t
*
i
)
{
in
t
val
=
0
;
machine_int_
t
mpz_as_int
(
const
mpz_t
*
i
)
{
machine_int_
t
val
=
0
;
mpz_dig_t
*
d
=
i
->
dig
+
i
->
len
;
while
(
--
d
>=
i
->
dig
)
{
in
t
oldval
=
val
;
machine_int_
t
oldval
=
val
;
val
=
(
val
<<
DIG_SIZE
)
|
*
d
;
if
(
val
<
oldval
)
{
...
...
This diff is collapsed.
Click to expand it.
py/mpz.h
+
3
−
3
View file @
aca14126
...
...
@@ -11,7 +11,7 @@ typedef struct _mpz_t {
mpz_dig_t
*
dig
;
}
mpz_t
;
bool
mpz_int_is_sml_int
(
in
t
i
);
bool
mpz_int_is_sml_int
(
machine_int_
t
i
);
void
mpz_init_zero
(
mpz_t
*
z
);
void
mpz_init_from_int
(
mpz_t
*
z
,
machine_int_t
val
);
...
...
@@ -35,7 +35,7 @@ bool mpz_is_odd(const mpz_t *z);
bool
mpz_is_even
(
const
mpz_t
*
z
);
int
mpz_cmp
(
const
mpz_t
*
lhs
,
const
mpz_t
*
rhs
);
int
mpz_cmp_sml_int
(
const
mpz_t
*
lhs
,
in
t
sml_int
);
int
mpz_cmp_sml_int
(
const
mpz_t
*
lhs
,
machine_int_
t
sml_int
);
mpz_t
*
mpz_abs
(
const
mpz_t
*
z
);
mpz_t
*
mpz_neg
(
const
mpz_t
*
z
);
...
...
@@ -58,7 +58,7 @@ void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const m
mpz_t
*
mpz_div
(
const
mpz_t
*
lhs
,
const
mpz_t
*
rhs
);
mpz_t
*
mpz_mod
(
const
mpz_t
*
lhs
,
const
mpz_t
*
rhs
);
in
t
mpz_as_int
(
const
mpz_t
*
z
);
machine_int_
t
mpz_as_int
(
const
mpz_t
*
z
);
machine_float_t
mpz_as_float
(
const
mpz_t
*
z
);
uint
mpz_as_str_size
(
const
mpz_t
*
z
,
uint
base
);
char
*
mpz_as_str
(
const
mpz_t
*
z
,
uint
base
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment