mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
handle yet another overflow case in numeric multiplication.
Turns out there were common factors between two fractions; by eliminating these first, significant rounding errors can be avoided. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10169 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
bc2faba5ff
commit
763b1ea012
@ -472,6 +472,24 @@ gnc_numeric_mul(gnc_numeric a, gnc_numeric b,
|
|||||||
|
|
||||||
/* If it looks to be overflowing, try to reduce the fraction ... */
|
/* If it looks to be overflowing, try to reduce the fraction ... */
|
||||||
if (bignume.isbig || bigdeno.isbig)
|
if (bignume.isbig || bigdeno.isbig)
|
||||||
|
{
|
||||||
|
gint64 tmp;
|
||||||
|
a = gnc_numeric_reduce (a);
|
||||||
|
b = gnc_numeric_reduce (b);
|
||||||
|
tmp = a.num;
|
||||||
|
a.num = b.num;
|
||||||
|
b.num = tmp;
|
||||||
|
a = gnc_numeric_reduce (a);
|
||||||
|
b = gnc_numeric_reduce (b);
|
||||||
|
|
||||||
|
bignume = mult128 (a.num, b.num);
|
||||||
|
bigdeno = mult128 (a.denom, b.denom);
|
||||||
|
product.num = a.num*b.num;
|
||||||
|
product.denom = a.denom*b.denom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If it its still overflowing, and rounding is allowed then round */
|
||||||
|
if (bignume.isbig || bigdeno.isbig)
|
||||||
{
|
{
|
||||||
/* If rounding allowed, then shift until there's no
|
/* If rounding allowed, then shift until there's no
|
||||||
* more overflow. The conversion at the end will fix
|
* more overflow. The conversion at the end will fix
|
||||||
|
Loading…
Reference in New Issue
Block a user