summaryrefslogtreecommitdiffstats
path: root/arith.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-01-22 19:05:42 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-01-22 19:05:42 -0800
commitceac286861928128d066b31c43e32a6034df0afb (patch)
tree9dbbc6c4ede2ba39f0d636f4f3a1c67a20f9aec6 /arith.c
parent812e34fccb1fe84d9127e2b294e6490e0bde4b00 (diff)
downloadtxr-ceac286861928128d066b31c43e32a6034df0afb.tar.gz
txr-ceac286861928128d066b31c43e32a6034df0afb.tar.bz2
txr-ceac286861928128d066b31c43e32a6034df0afb.zip
mpi: put access macros into mp_ namespace
* mpi/mpi.h (mp_sign, mp_isneg, mp_used, mp_alloc, mp_digits, mp_digit): New macros, based on renaming SIGN, ISNEG, USED, ALLOC, DIGITS and DIGIT. (mp_set_prec): Use mp_digits instead of DIGITS. * mpi/mpi.c (SIGN, ISNEG, USED, ALLOC, DIGITS, DIGIT): Macros defined here now, as local aliases for their namespaced counterparts. * arith.c (signum, floordiv): Replace ISNEG with mp_isneg. * rand.c (random): Replace ISNEG with mp_isneg. * sysif.c (off_t_num): Replace USED, DIGITS and ISNEG with mp_used, mp_digits and mp_isneg.
Diffstat (limited to 'arith.c')
-rw-r--r--arith.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/arith.c b/arith.c
index 8ba7fd21..62b53618 100644
--- a/arith.c
+++ b/arith.c
@@ -779,7 +779,7 @@ static val signum(val anum)
{
switch (type(anum)) {
case BGNUM:
- return if3(ISNEG(mp(anum)), negone, one);
+ return if3(mp_isneg(mp(anum)), negone, one);
case FLNUM:
{
double a = anum->fl.n;
@@ -1266,9 +1266,9 @@ tail:
cnum a = c_n(anum);
if (a == 0)
return zero;
- if (a < 0 && !ISNEG(mp(bnum)))
+ if (a < 0 && !mp_isneg(mp(bnum)))
return negone;
- if (a > 0 && ISNEG(mp(bnum)))
+ if (a > 0 && mp_isneg(mp(bnum)))
return negone;
return zero;
}
@@ -1301,8 +1301,8 @@ tail:
goto divzero;
if (b < 0)
mp_neg(mp(n), mp(n));
- if (rem && ((ISNEG(mp(anum)) && b > 0) ||
- (!ISNEG(mp(anum)) && b < 0)))
+ if (rem && ((mp_isneg(mp(anum)) && b > 0) ||
+ (!mp_isneg(mp(anum)) && b < 0)))
mpe = mp_sub_d(mp(n), 1, mp(n));
if (mpe != MP_OKAY)
do_mp_error(self, mpe);
@@ -1320,8 +1320,8 @@ tail:
goto divzero;
}
if (mp_cmp_z(&rem) != MP_EQ &&
- ((ISNEG(mp(anum)) && b > 0) ||
- (!ISNEG(mp(anum)) && b < 0)))
+ ((mp_isneg(mp(anum)) && b > 0) ||
+ (!mp_isneg(mp(anum)) && b < 0)))
mpe = mp_sub_d(mp(n), 1, mp(n));
mp_clear(&rem);
if (mpe != MP_OKAY)
@@ -1356,8 +1356,8 @@ tail:
goto divzero;
}
if (mp_cmp_z(&rem) != MP_EQ &&
- ((ISNEG(mp(anum)) && !ISNEG(mp(bnum))) ||
- (!ISNEG(mp(anum)) && ISNEG(mp(bnum)))))
+ ((mp_isneg(mp(anum)) && !mp_isneg(mp(bnum))) ||
+ (!mp_isneg(mp(anum)) && mp_isneg(mp(bnum)))))
mpe = mp_sub_d(mp(n), 1, mp(n));
mp_clear(&rem);
if (mpe != MP_OKAY)