diff options
Diffstat (limited to 'big.c')
-rw-r--r-- | big.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -562,21 +562,26 @@ word len(word x) return n; } -word msd(x) /* most significant digit of big x */ -word x; +/* most significant digit of big x */ +word msd(word x) { - while (rest(x)) + while (rest(x)) { x = rest(x); - return (digit(x)); /* sign? */ + } + + return digit(x); /* sign? */ } -word ms2d(x) /* most significant 2 digits of big x (len>=2) */ -word x; +/* most significant 2 digits of big x (len>=2) */ +word ms2d(word x) { word d = digit(x); x = rest(x); - while (rest(x)) - d = digit(x), x = rest(x); + while (rest(x)) { + d = digit(x); + x = rest(x); + } + return (digit(x) * IBASE + d); } |