summaryrefslogtreecommitdiff
path: root/strings/decimal.c
diff options
context:
space:
mode:
authorunknown <serg@sergbook.mylan>2004-11-08 10:06:32 +0100
committerunknown <serg@sergbook.mylan>2004-11-08 10:06:32 +0100
commit55e08c314ae835c45b7962aed1d3e985a3bbcbc8 (patch)
tree4655e2539bf7db777f80efbf669df08e10986d47 /strings/decimal.c
parent7b30603b0efd8ad1c809e0da4f83226689b140ac (diff)
downloadmariadb-git-55e08c314ae835c45b7962aed1d3e985a3bbcbc8.tar.gz
decimal.c:
test_ro("999999999999999999999.999", 0, CEILING); test_da("5", "-6.0"); ignore: added gdbinit BitKeeper/etc/ignore: added gdbinit strings/decimal.c: test_ro("999999999999999999999.999", 0, CEILING); test_da("5", "-6.0");
Diffstat (limited to 'strings/decimal.c')
-rw-r--r--strings/decimal.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 3d3ddc36116..09f6cb6bb51 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -921,6 +921,8 @@ int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode
*buf1-=DIG_BASE;
while (carry && --buf1 >= to->buf)
ADD(*buf1, *buf1, 0, carry);
+ if (to->buf[0] > from->buf[0])
+ to->intg++;
if (unlikely(carry))
{
/* shifting the number to create space for new digit */
@@ -1150,6 +1152,8 @@ static int do_sub(decimal *from1, decimal *from2, decimal *to)
buf1=start1+intg1+frac1;
stop1=start1+intg1+frac2;
buf2=start2+intg2+frac2;
+ while (frac0-- > frac1)
+ *--buf0=0;
while (buf1 > stop1)
*--buf0=*--buf1;
}
@@ -1158,6 +1162,8 @@ static int do_sub(decimal *from1, decimal *from2, decimal *to)
buf1=start1+intg1+frac1;
buf2=start2+intg2+frac2;
stop2=start2+intg2+frac1;
+ while (frac0-- > frac2)
+ *--buf0=0;
while (buf2 > stop2)
{
SUB(*--buf0, 0, *--buf2, carry);
@@ -1968,6 +1974,7 @@ main()
test_ds("-123.45", "-12345");
test_da("123.45", "-12345");
test_da("-123.45", "12345");
+ test_da("5", "-6.0");
printf("==== decimal_mul ====\n");
test_dm("12", "10");
@@ -2059,6 +2066,9 @@ main()
test_ro("-15.1",0,CEILING);
test_ro("15.1",0,FLOOR);
test_ro("-15.1",0,FLOOR);
+ test_ro("999999999999999999999.999", 0, CEILING);
+ test_ro("-999999999999999999999.999", 0, FLOOR);
+
return 0;
}