summaryrefslogtreecommitdiff
path: root/strings/decimal.c
diff options
context:
space:
mode:
authorunknown <holyfoot/hf@mysql.com/hfmain.(none)>2007-05-21 22:22:47 +0500
committerunknown <holyfoot/hf@mysql.com/hfmain.(none)>2007-05-21 22:22:47 +0500
commitcfb9378b3d7a1041752f0e2099494ec20d970baf (patch)
tree97cd5e0068c8bfdcd0bbf524552be2778b2e1e63 /strings/decimal.c
parent1e33cfb36a84b477a468dbcfc1ccc3035a9efb81 (diff)
downloadmariadb-git-cfb9378b3d7a1041752f0e2099494ec20d970baf.tar.gz
Bug #27984 Long Decimal Maths produces truncated results.
decimal_round failed to perform a correct rounding of a decimal number if its first nine digits were '9'. It just sets those digits to 0. mysql-test/r/type_newdecimal.result: Bug #27984 Long Decimal Maths produces truncated results. test result mysql-test/t/type_newdecimal.test: Bug #27984 Long Decimal Maths produces truncated results. test case strings/decimal.c: Bug #27984 Long Decimal Maths produces truncated results. when to == from we break the data if we do to->buf[0]=0 So now doing this after the data is moved and only if we really need to set to->buf[0] to zero
Diffstat (limited to 'strings/decimal.c')
-rw-r--r--strings/decimal.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 1ae75167794..f1f02f3a071 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1517,9 +1517,10 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
dec1 *p0= buf0+intg0+max(frac1, frac0);
dec1 *p1= buf1+intg1+max(frac1, frac0);
- to->buf[0]= 0;
while (buf0 < p0)
*(--p1) = *(--p0);
+ if (unlikely(intg1 > intg0))
+ to->buf[0]= 0;
intg0= intg1;
buf0=to->buf;