summaryrefslogtreecommitdiff
path: root/strings/decimal.c
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2005-06-15 19:56:01 +0500
committerunknown <hf@deer.(none)>2005-06-15 19:56:01 +0500
commit2ec50db87c1c46f575c82560d7935879e769da0e (patch)
treefdcb1312b7b03c16a125395b8f3ad91e2b89b000 /strings/decimal.c
parent04ec8eca81e420e7a0939b436757606f2fbc76c4 (diff)
parentdf60c7ef2dfffc0cc4b86da8b57449c11f7bbcbe (diff)
downloadmariadb-git-2ec50db87c1c46f575c82560d7935879e769da0e.tar.gz
Merge bk@192.168.21.1:/usr/home/bk/mysql-5.0
into deer.(none):/home/hf/work/mysql-5.0.10632 strings/decimal.c: Auto merged
Diffstat (limited to 'strings/decimal.c')
-rw-r--r--strings/decimal.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index de64933466d..18f920badd3 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1490,11 +1490,31 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
buf1+=intg0+frac0-1;
if (scale == frac0*DIG_PER_DEC1)
{
+ int do_inc= FALSE;
DBUG_ASSERT(frac0+intg0 >= 0);
- x=buf0[1]/DIG_MASK;
- if (x > round_digit ||
- (round_digit == 5 && x == 5 && (mode == HALF_UP ||
- (frac0+intg0 > 0 && *buf0 & 1))))
+ switch (round_digit)
+ {
+ case 0:
+ {
+ dec1 *p0= buf0 + (frac1-frac0);
+ for (; p0 > buf0; p0--)
+ if (*p0)
+ {
+ do_inc= TRUE;
+ break;
+ };
+ break;
+ }
+ case 5:
+ {
+ x= buf0[1]/DIG_MASK;
+ do_inc= (x>5) || ((x == 5) &&
+ (mode == HALF_UP || (frac0+intg0 > 0 && *buf0 & 1)));
+ break;
+ };
+ default:;
+ };
+ if (do_inc)
{
if (frac0+intg0>0)
(*buf1)++;
@@ -1509,6 +1529,7 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
}
else
{
+ /* TODO - fix this code as it won't work for CEILING mode */
int pos=frac0*DIG_PER_DEC1-scale-1;
DBUG_ASSERT(frac0+intg0 > 0);
x=*buf1 / powers10[pos];