diff options
Diffstat (limited to 'miscutils/bc.c')
-rw-r--r-- | miscutils/bc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 1879581..afd5c8d 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -6254,12 +6254,14 @@ static unsigned long bc_program_scale(BcNum *n) static unsigned long bc_program_len(BcNum *n) { - unsigned long len = n->len; - size_t i; - - if (n->rdx != n->len) return len; - for (i = n->len - 1; i < n->len && n->num[i] == 0; --len, --i); + size_t len = n->len; + if (n->rdx != len) return len; + for (;;) { + if (len == 0) break; + len--; + if (n->num[len] != 0) break; + } return len; } |