From ae94463be87baa4e826cd1e18a8ec94abc0a5a45 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Mon, 28 Mar 2022 14:54:40 -0400 Subject: modernize len() --- big.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/big.c b/big.c index 9f195d3..b438b3b 100644 --- a/big.c +++ b/big.c @@ -551,13 +551,15 @@ word longdiv(word x, word y) } } /* see Bird & Wadler p82 for explanation */ -word len(x) /* no of digits in big x */ -word x; +/* no of digits in big x */ +word len(word x) { word n = 1; - while (x = rest(x)) + while (x = rest(x)) { n++; - return (n); + } + + return n; } word msd(x) /* most significant digit of big x */ -- cgit v1.2.1