mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
Fix gcdrat to return correct optimization only
This commit is contained in:
parent
36c23fba24
commit
032a7da930
1 changed files with 8 additions and 3 deletions
|
@ -44,7 +44,7 @@ void gcdrat( PRAT *pa, int32_t precision)
|
||||||
PNUMBER pgcd= nullptr;
|
PNUMBER pgcd= nullptr;
|
||||||
PRAT a= nullptr;
|
PRAT a= nullptr;
|
||||||
|
|
||||||
a=*pa;
|
DUPRAT(a,*pa);
|
||||||
pgcd = gcd( a->pp, a->pq );
|
pgcd = gcd( a->pp, a->pq );
|
||||||
|
|
||||||
if ( !zernum( pgcd ) )
|
if ( !zernum( pgcd ) )
|
||||||
|
@ -54,9 +54,14 @@ void gcdrat( PRAT *pa, int32_t precision)
|
||||||
}
|
}
|
||||||
|
|
||||||
destroynum( pgcd );
|
destroynum( pgcd );
|
||||||
*pa=a;
|
|
||||||
|
|
||||||
RENORMALIZE(*pa);
|
RENORMALIZE(a);
|
||||||
|
|
||||||
|
if (rat_equ(*pa, a, precision))
|
||||||
|
{
|
||||||
|
DUPRAT(*pa, a);
|
||||||
|
}
|
||||||
|
destroyrat(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue