mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
Set a default base of base64 for Rational class.
This commit is contained in:
parent
3cef85695d
commit
43bd7bb16e
5 changed files with 21 additions and 21 deletions
|
@ -302,9 +302,9 @@ wstring CalcInput::ToString(uint32_t radix, bool isIntegerMode)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rational CalcInput::ToRational(int32_t precision)
|
Rational CalcInput::ToRational(uint32_t radix, int32_t precision)
|
||||||
{
|
{
|
||||||
PRAT rat = StringToRat(m_base.IsNegative(), m_base.value, m_exponent.IsNegative(), m_exponent.value, BASEX, precision);
|
PRAT rat = StringToRat(m_base.IsNegative(), m_base.value, m_exponent.IsNegative(), m_exponent.value, radix, precision);
|
||||||
if (rat == nullptr)
|
if (rat == nullptr)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -139,7 +139,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
|
||||||
(IDC_SIGN == wParam && 10 != m_radix))
|
(IDC_SIGN == wParam && 10 != m_radix))
|
||||||
{
|
{
|
||||||
m_bRecord = false;
|
m_bRecord = false;
|
||||||
m_currentVal = m_input.ToRational(m_precision);
|
m_currentVal = m_input.ToRational(m_radix, m_precision);
|
||||||
DisplayNum(); // Causes 3.000 to shrink to 3. on first op.
|
DisplayNum(); // Causes 3.000 to shrink to 3. on first op.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -651,7 +651,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
|
||||||
case IDM_BYTE:
|
case IDM_BYTE:
|
||||||
if (m_bRecord)
|
if (m_bRecord)
|
||||||
{
|
{
|
||||||
m_currentVal = m_input.ToRational(m_precision);
|
m_currentVal = m_input.ToRational(m_radix, m_precision);
|
||||||
m_bRecord = false;
|
m_bRecord = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1018,7 +1018,7 @@ int CCalcEngine::GetCurrentRadix()
|
||||||
|
|
||||||
wstring CCalcEngine::GetCurrentResultForRadix(uint32_t radix, int32_t precision)
|
wstring CCalcEngine::GetCurrentResultForRadix(uint32_t radix, int32_t precision)
|
||||||
{
|
{
|
||||||
Rational rat = (m_bRecord ? m_input.ToRational(m_precision) : m_currentVal);
|
Rational rat = (m_bRecord ? m_input.ToRational(m_radix, m_precision) : m_currentVal);
|
||||||
|
|
||||||
ChangeConstants(m_radix, precision);
|
ChangeConstants(m_radix, precision);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace CalcEngine
|
||||||
void Backspace();
|
void Backspace();
|
||||||
void SetDecimalSymbol(wchar_t decSymbol);
|
void SetDecimalSymbol(wchar_t decSymbol);
|
||||||
std::wstring ToString(uint32_t radix, bool isIntegerMode);
|
std::wstring ToString(uint32_t radix, bool isIntegerMode);
|
||||||
Rational ToRational(int32_t precision);
|
Rational ToRational(uint32_t radix, int32_t precision);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_hasExponent;
|
bool m_hasExponent;
|
||||||
|
|
|
@ -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 );
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue