Revert Rational default base to 64 and uncomment code to convert to/from strings in intrat/fracrat, to resolve rounding errors.

This commit is contained in:
Josh Koon 2019-02-21 10:00:30 -08:00
commit 9c6ef250d0
2 changed files with 15 additions and 15 deletions

View file

@ -75,15 +75,15 @@ void fracrat( PRAT *pa , uint32_t radix, int32_t precision)
{
// Only do the intrat operation if number is nonzero.
// and only if the bottom part is not one.
//if ( !zernum( (*pa)->pp ) && !equnum( (*pa)->pq, num_one ) )
//{
// wstring ratStr = RatToString(*pa, FMT_FLOAT, radix, precision);
// PNUMBER pnum = StringToNumber(ratStr, radix, precision);
//
// destroyrat( *pa );
// *pa = numtorat( pnum, radix);
// destroynum( pnum );
//}
if ( !zernum( (*pa)->pp ) && !equnum( (*pa)->pq, num_one ) )
{
wstring ratStr = RatToString(*pa, FMT_FLOAT, radix, precision);
PNUMBER pnum = StringToNumber(ratStr, radix, precision);
destroyrat( *pa );
*pa = numtorat( pnum, radix);
destroynum( pnum );
}
remnum( &((*pa)->pp), (*pa)->pq, BASEX );

View file

@ -291,12 +291,12 @@ void intrat( PRAT *px, uint32_t radix, int32_t precision)
// and only if the bottom part is not one.
if ( !zernum( (*px)->pp ) && !equnum( (*px)->pq, num_one ) )
{
//wstring ratStr = RatToString(*px, FMT_FLOAT, radix, precision);
//PNUMBER pnum = StringToNumber(ratStr, radix, precision);
//
//destroyrat( *px );
//*px = numtorat( pnum, radix);
//destroynum( pnum );
wstring ratStr = RatToString(*px, FMT_FLOAT, radix, precision);
PNUMBER pnum = StringToNumber(ratStr, radix, precision);
destroyrat( *px );
*px = numtorat( pnum, radix);
destroynum( pnum );
PRAT pret = nullptr;
DUPRAT(pret,*px);