diff options
author | unknown <hf@deer.(none)> | 2005-09-04 21:00:00 +0500 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2005-09-04 21:00:00 +0500 |
commit | d96cf23c9a64adaf823b45cf0a0ff0e39babbe88 (patch) | |
tree | efdc0cf38ef610b035888be5f338560aa075b98b /strings | |
parent | d6b70bf4aeee0bfbb74a2ae6a3d7e8617531b1b7 (diff) | |
download | mariadb-git-d96cf23c9a64adaf823b45cf0a0ff0e39babbe88.tar.gz |
Fix for bug #12938 (decimal arithmetic in the loop fails)
mysql-test/r/type_newdecimal.result:
test result fixed
mysql-test/t/type_newdecimal.test:
test case added
strings/decimal.c:
code to cut heading zeroes off the result of the multiplication added
Diffstat (limited to 'strings')
-rw-r--r-- | strings/decimal.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/strings/decimal.c b/strings/decimal.c index 4dc5fa91e0a..7816f340eef 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1933,7 +1933,7 @@ int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to) int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg), frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac), intg0=ROUND_UP(from1->intg+from2->intg), - frac0=frac1+frac2, error, i, j; + frac0=frac1+frac2, error, i, j, d_to_move; dec1 *buf1=from1->buf+intg1, *buf2=from2->buf+intg2, *buf0, *start2, *stop2, *stop1, *start0, carry; @@ -2007,6 +2007,20 @@ int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to) } } } + buf1= to->buf; + d_to_move= intg0 + ROUND_UP(to->frac); + while (!*buf1 && (to->intg > DIG_PER_DEC1)) + { + buf1++; + to->intg-= DIG_PER_DEC1; + d_to_move--; + } + if (to->buf < buf1) + { + dec1 *cur_d= to->buf; + for (; d_to_move; d_to_move--, cur_d++, buf1++) + *cur_d= *buf1; + } return error; } |