mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
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:
parent
999027da10
commit
a163095ac5
3 changed files with 16 additions and 16 deletions
|
@ -9,7 +9,7 @@ namespace CalcEngine
|
|||
// Default Base/Radix to use for Rational calculations
|
||||
// Defaults to base 64 rather than the RatPack-internal BASEX because many
|
||||
// calculations do not support bases > 64.
|
||||
static constexpr uint32_t DEFAULT_BASE = BASEX;
|
||||
static constexpr uint32_t DEFAULT_BASE = 64;
|
||||
|
||||
class Rational
|
||||
{
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue