diff options
Diffstat (limited to 'big.c')
-rw-r--r-- | big.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -17,6 +17,13 @@ #define MAX_INT_BITS 60 #define LONG_LONG_OVERFLOW (1ll<<MAX_INT_BITS) +#define PTEN 10000 /* largest power of ten < IBASE (used by bigscan) */ +#define PSIXTEEN 4096 /* largest power of sixteen <= IBASE (used by bigtostr) */ +#define PEIGHT 0100000 /* (=32768) largest power of eight <= IBASE (used by bigtostr) */ +#define TENW 4 /* number of factors of 10 in PTEN */ +#define OCTW 5 /* number of factors of 8 in IBASE */ +#define DIGITWIDTH 15 + word big_one; static word big_plus(word, word, int); @@ -116,7 +123,7 @@ word bigplus(word x, word y) word big_plus(word x, word y, int signbit) { word d = digit0(x) + digit0(y); - word r = make(INT, signbit | d & MAXDIGIT, 0); /* result */ + word r = make(INT, signbit | (d & MAXDIGIT), 0); /* result */ word *z = &rest(r); /* pointer to rest of result */ word carry = ((d & IBASE) != 0); @@ -338,7 +345,7 @@ word stimes(word x, word n) word r = make(INT, d & MAXDIGIT, 0); word *y = &rest(r); - while (x = rest(x)) { + while ((x = rest(x)) != 0) { d = n * digit(x) + carry; *y = make(INT, d & MAXDIGIT, 0); y = &rest(*y); @@ -443,7 +450,7 @@ word shortdiv(word x, word n) word q = 0; /* reverse rest(x) into q */ - while (x = rest(x)) { + while ((x = rest(x)) != 0) { q = make(INT, d, q); d = digit(x); /* leaving most sig. digit in d */ } @@ -551,7 +558,7 @@ word longdiv(word x, word y) word len(word x) { word n = 1; - while (x = rest(x)) { + while ((x = rest(x)) != 0) { n++; } @@ -917,7 +924,7 @@ word bigtostr(word x) sign = big_is_negative(x); x1 = make(INT, digit0(x), 0); /* reverse x into x1 */ - while (x = rest(x)) { + while ((x = rest(x)) != 0) { x1 = make(INT, digit(x), x1); } x = x1; |