~mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
symm/cbc-def.h: Fix discarding output for short inputs.
[catacomb]
/
math
/
mp-gcd.c
diff --git
a/math/mp-gcd.c
b/math/mp-gcd.c
index
6e059e3
..
3192f94
100644
(file)
--- a/
math/mp-gcd.c
+++ b/
math/mp-gcd.c
@@
-58,13
+58,10
@@
void mp_gcd(mp **gcd, mp **xx, mp **yy, mp *a, mp *b)
/* --- Sort out some initial flags --- */
/* --- Sort out some initial flags --- */
- if (xx || yy)
- f |= f_ext;
+ if (xx || yy) f |= f_ext;
- if (MP_NEGP(a))
- f |= f_aneg;
- if (MP_NEGP(b))
- f |= f_bneg;
+ if (MP_NEGP(a)) f |= f_aneg;
+ if (MP_NEGP(b)) f |= f_bneg;
/* --- Ensure that @a@ is larger than @b@ --- *
*
/* --- Ensure that @a@ is larger than @b@ --- *
*
@@
-101,12
+98,9
@@
void mp_gcd(mp **gcd, mp **xx, mp **yy, mp *a, mp *b)
}
if (xx) {
if (*xx) MP_DROP(*xx);
}
if (xx) {
if (*xx) MP_DROP(*xx);
- if (MP_EQ(a, MP_ZERO))
- *xx = MP_ZERO;
- else if (f & f_aneg)
- *xx = MP_MONE;
- else
- *xx = MP_ONE;
+ if (MP_EQ(a, MP_ZERO)) *xx = MP_ZERO;
+ else if (f & f_aneg) *xx = MP_MONE;
+ else *xx = MP_ONE;
}
if (yy) {
if (*yy) MP_DROP(*yy);
}
if (yy) {
if (*yy) MP_DROP(*yy);
@@
-187,22
+181,16
@@
void mp_gcd(mp **gcd, mp **xx, mp **yy, mp *a, mp *b)
}
}
} else {
}
}
} else {
- if (MP_NEGP(x)) {
- do
- x = mp_add(x, x, b);
- while (MP_NEGP(x));
- } else {
- while (MP_CMP(x, >=, b))
- x = mp_sub(x, x, b);
- }
+ if (MP_NEGP(x))
+ do x = mp_add(x, x, b); while (MP_NEGP(x));
+ else
+ while (MP_CMP(x, >=, b)) x = mp_sub(x, x, b);
}
/* --- Twiddle the signs --- */
}
/* --- Twiddle the signs --- */
- if (f & f_aneg)
- x->f ^= MP_NEG;
- if (f & f_bneg)
- y->f ^= MP_NEG;
+ if (f & f_aneg) { MP_SPLIT(x); x->f ^= MP_NEG; }
+ if (f & f_bneg) { MP_SPLIT(y); y->f ^= MP_NEG; }
/* --- Store the results --- */
/* --- Store the results --- */