summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--big.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/big.c b/big.c
index 1b276e2..72842fc 100644
--- a/big.c
+++ b/big.c
@@ -27,35 +27,38 @@ static word shift(word, word);
static word shortdiv(word, word);
static word stimes(word, word);
-void bigsetup()
+void bigsetup(void)
{
logIBASE = log((double)IBASE);
log10IBASE = log10((double)IBASE);
big_one = make(INT, 1, 0);
}
-int isnat(x)
-word x;
+int isnat(word x)
{
return (tag[x] == INT && big_is_positive(x));
}
-word sto_int(i) /* store C long long as mira bigint */
-long long i;
+/* store C long long as mira bigint */
+word sto_int(long long i)
{
- word s, x;
- if (i < 0)
- s = SIGNBIT, i = -i;
- else
- s = 0;
- x = make(INT, s | i & MAXDIGIT, 0);
+ word sign = 0;
+
+ if (i < 0) {
+ sign = SIGNBIT;
+ i = -i;
+ }
+
+ word x = make(INT, (sign | i) & MAXDIGIT, 0);
if (i >>= DIGITWIDTH) {
word *p = &rest(x);
- *p = make(INT, i & MAXDIGIT, 0), p = &rest(*p);
- while (i >>= DIGITWIDTH)
- *p = make(INT, i & MAXDIGIT, 0), p = &rest(*p);
+ do {
+ *p = make(INT, i & MAXDIGIT, 0);
+ p = &rest(*p);
+ } while (i >>= DIGITWIDTH);
}
- return (x);
+
+ return x;
} /* change to long long, DT Oct 2019 */
#define maxval (1ll<<60)