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 a163095ac5
3 changed files with 16 additions and 16 deletions

View file

@ -9,7 +9,7 @@ namespace CalcEngine
// Default Base/Radix to use for Rational calculations // Default Base/Radix to use for Rational calculations
// Defaults to base 64 rather than the RatPack-internal BASEX because many // Defaults to base 64 rather than the RatPack-internal BASEX because many
// calculations do not support bases > 64. // calculations do not support bases > 64.
static constexpr uint32_t DEFAULT_BASE = BASEX; static constexpr uint32_t DEFAULT_BASE = 64;
class Rational class Rational
{ {

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. // Only do the intrat operation if number is nonzero.
// and only if the bottom part is not one. // and only if the bottom part is not one.
//if ( !zernum( (*pa)->pp ) && !equnum( (*pa)->pq, num_one ) ) if ( !zernum( (*pa)->pp ) && !equnum( (*pa)->pq, num_one ) )
//{ {
// wstring ratStr = RatToString(*pa, FMT_FLOAT, radix, precision); wstring ratStr = RatToString(*pa, FMT_FLOAT, radix, precision);
// PNUMBER pnum = StringToNumber(ratStr, radix, precision); PNUMBER pnum = StringToNumber(ratStr, radix, precision);
//
// destroyrat( *pa ); destroyrat( *pa );
// *pa = numtorat( pnum, radix); *pa = numtorat( pnum, radix);
// destroynum( pnum ); destroynum( pnum );
//} }
remnum( &((*pa)->pp), (*pa)->pq, BASEX ); 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. // and only if the bottom part is not one.
if ( !zernum( (*px)->pp ) && !equnum( (*px)->pq, num_one ) ) if ( !zernum( (*px)->pp ) && !equnum( (*px)->pq, num_one ) )
{ {
//wstring ratStr = RatToString(*px, FMT_FLOAT, radix, precision); wstring ratStr = RatToString(*px, FMT_FLOAT, radix, precision);
//PNUMBER pnum = StringToNumber(ratStr, radix, precision); PNUMBER pnum = StringToNumber(ratStr, radix, precision);
//
//destroyrat( *px ); destroyrat( *px );
//*px = numtorat( pnum, radix); *px = numtorat( pnum, radix);
//destroynum( pnum ); destroynum( pnum );
PRAT pret = nullptr; PRAT pret = nullptr;
DUPRAT(pret,*px); DUPRAT(pret,*px);