diff options
author | unknown <serg@serg.mylan> | 2004-11-07 16:12:21 +0100 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2004-11-07 16:12:21 +0100 |
commit | 7b30603b0efd8ad1c809e0da4f83226689b140ac (patch) | |
tree | f01bb583cc68af97a3a0429cf762e8b5b46c0d43 /strings/decimal.c | |
parent | fc99b5217c426373acdb4ce909b499e63d970294 (diff) | |
download | mariadb-git-7b30603b0efd8ad1c809e0da4f83226689b140ac.tar.gz |
don't return intg=frac=0 from mod
Diffstat (limited to 'strings/decimal.c')
-rw-r--r-- | strings/decimal.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/strings/decimal.c b/strings/decimal.c index c65078a44bf..3d3ddc36116 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -206,7 +206,7 @@ int decimal2string(decimal *from, char *to, int *to_len) char *s=to; dec1 *buf, *buf0=from->buf, tmp; - DBUG_ASSERT(*to_len > 2+from->sign); + DBUG_ASSERT(*to_len >= 2+from->sign); /* removing leading zeroes */ i=((intg-1) % DIG_PER_DEC1)+1; @@ -1511,6 +1511,11 @@ static int do_div_mod(decimal *from1, decimal *from2, intg0=ROUND_UP(prec1-frac1)-(start1-tmp1); frac0=ROUND_UP(to->frac); error=E_DEC_OK; + if (unlikely(frac0==0 && intg0==0)) + { + decimal_make_zero(to); + goto done; + } if (intg0<=0) { if (unlikely(-intg0 >= to->len)) |