summaryrefslogtreecommitdiff
path: root/strings/decimal.c
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-10-09 10:30:11 +0200
committerSergei Golubchik <sergii@pisem.net>2014-10-09 10:30:11 +0200
commit1b75bed00fa4ea3925f513f4825deb00cb158d5b (patch)
tree0822ed2a2ca42ba1acb82a6737336bbfe219bebe /strings/decimal.c
parent689ffe3559a4b7bacd13503ba93659b2f4560bbb (diff)
parentb2d71434ed24d0901155fe68b0b7ee4fdad0e2d4 (diff)
downloadmariadb-git-1b75bed00fa4ea3925f513f4825deb00cb158d5b.tar.gz
5.5.40+ merge
Diffstat (limited to 'strings/decimal.c')
-rw-r--r--strings/decimal.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 1b6ffbb110b..979f1b179f9 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2004, 2013, Oracle and/or its affiliates.
- Copyright (c) 2009, 2013, Monty Program Ab
+/* Copyright (c) 2004, 2014, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2014, Monty Program Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -127,7 +127,6 @@ typedef longlong dec2;
#define DIG_BASE 1000000000
#define DIG_MAX (DIG_BASE-1)
#define DIG_BASE2 ((dec2)DIG_BASE * (dec2)DIG_BASE)
-#define ROUND_UP(X) (((X)+DIG_PER_DEC1-1)/DIG_PER_DEC1)
static const dec1 powers10[DIG_PER_DEC1+1]={
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
static const int dig2bytes[DIG_PER_DEC1+1]={0, 1, 1, 2, 2, 3, 3, 4, 4, 4};
@@ -136,6 +135,11 @@ static const dec1 frac_max[DIG_PER_DEC1-1]={
999900000, 999990000, 999999000,
999999900, 999999990 };
+static inline int ROUND_UP(int x)
+{
+ return (x + (x > 0 ? DIG_PER_DEC1 - 1 : 0)) / DIG_PER_DEC1;
+}
+
#ifdef HAVE_valgrind
#define sanity(d) DBUG_ASSERT((d)->len > 0)
#else
@@ -2329,7 +2333,7 @@ static int do_div_mod(const decimal_t *from1, const decimal_t *from2,
error=E_DEC_TRUNCATED;
goto done;
}
- stop1=start1+frac0;
+ stop1= start1 + frac0 + intg0;
frac0+=intg0;
to->intg=0;
while (intg0++ < 0)