summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
Diffstat (limited to 'strings')
-rw-r--r--strings/decimal.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 76e62080ba0..1d75502f0da 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1443,6 +1443,7 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
intg1=ROUND_UP(from->intg +
(((intg0 + frac0)>0) && (from->buf[0] == DIG_MAX)));
dec1 *buf0=from->buf, *buf1=to->buf, x, y, carry=0;
+ int first_dig;
sanity(to);
@@ -1578,14 +1579,6 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
*buf1=1;
to->intg++;
}
- else
- {
- /* Here we check 999.9 -> 1000 case when we need to increase intg */
- int first_dig= to->intg % DIG_PER_DEC1;
- /* first_dig==0 should be handled above in the 'if' */
- if (first_dig && (*buf1 >= powers10[first_dig]))
- to->intg++;
- }
}
else
{
@@ -1606,6 +1599,12 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
}
}
}
+
+ /* Here we check 999.9 -> 1000 case when we need to increase intg */
+ first_dig= to->intg % DIG_PER_DEC1;
+ if (first_dig && (*buf1 >= powers10[first_dig]))
+ to->intg++;
+
if (scale<0)
scale=0;