mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user