summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-03-28 16:49:13 -0400
committerJakob Kaivo <jkk@ung.org>2022-03-28 16:49:13 -0400
commit0c061784519c069853ba9e9794fc4ec41d0668f9 (patch)
tree0f6f2732d5319bb8a5df36ee875d63653183ac1e
parentb7220bcd1a054872e081afc77b305f0247bf3f98 (diff)
rename bigzero() to big_is_zero()
-rw-r--r--big.c16
-rw-r--r--big.h3
-rw-r--r--reduce.c8
3 files changed, 13 insertions, 14 deletions
diff --git a/big.c b/big.c
index 35f27b5..120748b 100644
--- a/big.c
+++ b/big.c
@@ -419,7 +419,7 @@ long long big_toll(word x)
word big_negate(word x)
{
- if (bigzero(x)) {
+ if (big_is_zero(x)) {
return x;
}
@@ -506,7 +506,7 @@ word big_multiply(word x, word y)
word r = make(INT, 0, 0);
/* short cut */
- if (bigzero(x)) {
+ if (big_is_zero(x)) {
return (r);
}
@@ -542,7 +542,7 @@ word big_divide(word x, word y)
word q = bd.quo;
if (s2) {
- if (!bigzero(bd.rem)) {
+ if (!big_is_zero(bd.rem)) {
x = q;
while ((digit(x) += 1) == IBASE) { /* add 1 to q in situ */
digit(x) = 0;
@@ -553,7 +553,7 @@ word big_divide(word x, word y)
x = rest(x);
}
}
- if (!bigzero(q)) {
+ if (!big_is_zero(q)) {
digit(q) = SIGNBIT | digit(q);
}
}
@@ -581,7 +581,7 @@ word big_remainder(word x, word y)
struct big_div bd = rest(y) ? big__longdiv(x, y) : big__shortdiv(x, digit(y));
if (s2) {
- if (!bigzero(bd.rem)) {
+ if (!big_is_zero(bd.rem)) {
bd.rem = big_subtract(y, bd.rem);
}
}
@@ -695,7 +695,7 @@ static double big__log(word x, double logbase, char *name, double (*fn)(double))
word n = 0;
double r = digit(x);
- if (big_is_negative(x) || bigzero(x)) {
+ if (big_is_negative(x) || big_is_zero(x)) {
errno = EDOM;
math_error(name);
}
@@ -772,7 +772,7 @@ word bigscan(char *p)
}
}
- if (s && !bigzero(r)) {
+ if (s && !big_is_zero(r)) {
digit(r) = digit(r) | SIGNBIT;
}
@@ -889,7 +889,7 @@ word strtobig(word z, int base)
}
}
- if (s && !bigzero(r)) {
+ if (s && !big_is_zero(r)) {
digit(r) = digit(r) | SIGNBIT;
}
diff --git a/big.h b/big.h
index 9eb1406..9cfa12b 100644
--- a/big.h
+++ b/big.h
@@ -11,14 +11,13 @@
#define SIGNBIT 020000000000 /* most significant bit of 32 bit word */
#define IBASE 0100000 /* 2^15 (ie 8^5) so digit is a positive short */
#define MAXDIGIT 077777
-#define DIGITWIDTH 15
#define digit0(x) (hd[x]&MAXDIGIT)
#define digit(x) hd[x]
#define rest(x) tl[x]
#define big_is_positive(x) (!(hd[x]&SIGNBIT))
#define big_is_negative(x) (hd[x]&SIGNBIT)
-#define bigzero(x) (!digit(x)&&!rest(x))
+#define big_is_zero(x) (!digit(x)&&!rest(x))
#define getsmallint(x) (hd[x]&SIGNBIT?-digit0(x):digit(x))
#define stosmallint(x) make(INT,(x)<0?SIGNBIT|(-(x)):(x),0)
diff --git a/reduce.c b/reduce.c
index 6c61f9a..f0a9101 100644
--- a/reduce.c
+++ b/reduce.c
@@ -2075,7 +2075,7 @@ L3: if(arg1==NIL)lexfail(lastarg);
GETARG(arg1);
UPLEFT;
if(tag[arg1]==DOUBLE||tag[lastarg]==DOUBLE)int_error("div");
- if(bigzero(lastarg))div_error(); /* build into big_remainder ? */
+ if(big_is_zero(lastarg))div_error(); /* build into big_remainder ? */
simpl(big_divide(arg1,lastarg));
goto DONE;
@@ -2084,10 +2084,10 @@ L3: if(arg1==NIL)lexfail(lastarg);
GETARG(arg1);
UPLEFT;
/* experiment, suppressed
- if(tag[lastarg]==INT&&tag[arg1]==INT&&!bigzero(lastarg))
+ if(tag[lastarg]==INT&&tag[arg1]==INT&&!big_is_zero(lastarg))
{ extern word b_rem;
int d = big_divide(arg1,lastarg);
- if(bigzero(b_rem)){ simpl(d); goto DONE; }
+ if(big_is_zero(b_rem)){ simpl(d); goto DONE; }
} /* makes a/b integer if a, b integers dividing exactly */
fa=force_dbl(arg1);
fb=force_dbl(lastarg);
@@ -2100,7 +2100,7 @@ L3: if(arg1==NIL)lexfail(lastarg);
GETARG(arg1);
UPLEFT;
if(tag[arg1]==DOUBLE||tag[lastarg]==DOUBLE)int_error("mod");
- if(bigzero(lastarg))div_error(); /* build into big_remainder ? */
+ if(big_is_zero(lastarg))div_error(); /* build into big_remainder ? */
simpl(big_remainder(arg1,lastarg));
goto DONE;