summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-03-28 14:56:17 -0400
committerJakob Kaivo <jkk@ung.org>2022-03-28 14:56:17 -0400
commit8a1de9cc709b2a9470541a229d2134f022a28301 (patch)
treeb681d46ba5587d3d0e9495c75eeb499ddfd54dcc
parentae94463be87baa4e826cd1e18a8ec94abc0a5a45 (diff)
modernize msd() and ms2d()
-rw-r--r--big.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/big.c b/big.c
index b438b3b..02753f6 100644
--- a/big.c
+++ b/big.c
@@ -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);
}