summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2005-06-09 12:44:44 +0500
committerunknown <hf@deer.(none)>2005-06-09 12:44:44 +0500
commit98c2ec75387113c265f4eaa9c66c28577516d51b (patch)
tree7b9485358c355338e2ed1b391516a4952eab6416 /strings
parent0537106bef083d3f413dc117168205ddce5796b5 (diff)
downloadmariadb-git-98c2ec75387113c265f4eaa9c66c28577516d51b.tar.gz
Fix for bug #8482 (Incorrect rounding)
mysql-test/r/type_newdecimal.result: test result fixed mysql-test/t/type_newdecimal.test: test case added strings/decimal.c: in round(999.9, 0) case we have to increase intg
Diffstat (limited to 'strings')
-rw-r--r--strings/decimal.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 787d00dcb46..4a487f3c9b0 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1546,6 +1546,14 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
*buf1=1;
to->intg++;
}
+ /* Here we check 999.9 -> 1000 case when we need to increase intg */
+ else
+ {
+ 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
{