summaryrefslogtreecommitdiff
path: root/strings/decimal.c
diff options
context:
space:
mode:
authorserg@serg.mylan <>2004-12-03 13:23:58 +0100
committerserg@serg.mylan <>2004-12-03 13:23:58 +0100
commitc0a4183b0cf50fb785ee1b689f68e97170fcd0e3 (patch)
treec10a351082fed7a32426a4db1c35da8a17391616 /strings/decimal.c
parent44dce2673e1f0f6375faed522da71eeaf2e1c6aa (diff)
downloadmariadb-git-c0a4183b0cf50fb785ee1b689f68e97170fcd0e3.tar.gz
strings/decimal.c
decimal_round(d, -N) bug fixed
Diffstat (limited to 'strings/decimal.c')
-rw-r--r--strings/decimal.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 1c743a24b69..224d75f6844 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -921,6 +921,12 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode
x+=10;
*buf1=powers10[pos]*(x-y);
}
+ if (frac0 < 0)
+ {
+ dec1 *end=to->buf+intg0, *buf=buf1+1;
+ while (buf < end)
+ *buf++=0;
+ }
if (*buf1 >= DIG_BASE)
{
carry=1;
@@ -2083,6 +2089,7 @@ main()
test_ro("5678.123451",5,TRUNCATE,"5678.12345");
test_ro("5678.123451",6,TRUNCATE,"5678.123451");
test_ro("-5678.123451",-4,TRUNCATE,"0");
+ memset(buf2, 33, sizeof(buf2));
test_ro("99999999999999999999999999999999999999",-31,TRUNCATE,"99999990000000000000000000000000000000");
test_ro("15.1",0,HALF_UP,"15");
test_ro("15.5",0,HALF_UP,"16");