summaryrefslogtreecommitdiff
path: root/miscutils/bc.c
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils/bc.c')
-rw-r--r--miscutils/bc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index c364864..ca95069 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;
+ }
}
}