diff options
author | Jakob Kaivo <jkk@ung.org> | 2022-03-28 15:00:34 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2022-03-28 15:00:34 -0400 |
commit | 9fc3c369e0de14c7a8df081ec35f9283088e6891 (patch) | |
tree | bd885c0f4e043d9566958b0448640e800fca5e1e | |
parent | f9a8d0b1205d3772d27c0e8e8a8dccda2f3c66ca (diff) |
modernize bigtodbl()
-rw-r--r-- | big.c | 30 |
1 files changed, 10 insertions, 20 deletions
@@ -620,34 +620,24 @@ word bigpow(word x, word y) return r; } -double bigtodbl(x) -word x; +double bigtodbl(word x) { word s = big_is_negative(x); - double b = 1.0, r = (double)digit0(x); + double b = 1.0; + double r = (double)digit0(x); x = rest(x); - while (x) - b = b * IBASE, r = r + b * digit(x), x = rest(x); - if (s) - return (-r); - return (r); + while (x) { + b = b * IBASE; + r = r + b * digit(x); + x = rest(x); + } + + return s ? -r : r; } /* small end first */ /* note: can return oo, -oo but is used without surrounding sto_/set)dbl() only in compare() */ -/* not currently used -long double bigtoldbl(x) -word x; -{ int s=big_is_negative(x); - long double b=1.0L, r=digit0(x); - x = rest(x); - while(x)b=b*IBASE,r=r+b*digit(x),x=rest(x); -/*printf("bigtoldbl returns %Le\n",s?-r:r); /* DEBUG - if(s)return(-r); - return(r); -} /* not compatible with std=c90, lib fns eg sqrtl broken */ - word dbltobig(x) /* entier */ double x; { |