diff options
-rw-r--r-- | miscutils/bc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index c36486414..ca9506929 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -2246,8 +2246,14 @@ static void bc_num_parseDecimal(BcNum *n, const char *val) n->rdx = (size_t)((val + len) - (ptr + 1)); if (!zero) { - for (i = len - 1; i < len; ++n->len, i -= 1 + (i && val[i - 1] == '.')) + i = len - 1; + for (;;) { n->num[n->len] = val[i] - '0'; + ++n->len; + skip_dot: + if ((ssize_t)--i == (ssize_t)-1) break; + if (val[i] == '.') goto skip_dot; + } } } |