mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-16 02:02:51 -07:00
Convert ExpressionCommand and History collector to use Rational instead of PRAT
This commit is contained in:
parent
c13b8a099e
commit
4883fab7f7
5 changed files with 31 additions and 60 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "ExpressionCommand.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace CalcEngine;
|
||||
|
||||
constexpr wchar_t chNegate = L'-';
|
||||
constexpr wchar_t chExp = L'e';
|
||||
|
@ -95,25 +96,12 @@ void CBinaryCommand::Accept(_In_ ISerializeCommandVisitor &commandVisitor)
|
|||
}
|
||||
|
||||
COpndCommand::COpndCommand(_In_ shared_ptr<CalculatorVector<int>> const &commands,
|
||||
_In_ bool fNegative,
|
||||
_In_ bool fDecimal,
|
||||
_In_ bool fSciFmt) :
|
||||
m_commands(commands), m_fNegative(fNegative), m_fDecimal(fDecimal), m_fSciFmt(fSciFmt)
|
||||
{
|
||||
m_hnoNum = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void COpndCommand::Initialize(_In_ PRAT hNoNum)
|
||||
{
|
||||
assert(&m_hnoNum != nullptr);
|
||||
if (m_hnoNum != nullptr)
|
||||
{
|
||||
destroyrat(m_hnoNum);
|
||||
m_hnoNum = nullptr;
|
||||
}
|
||||
DUPRAT(m_hnoNum, hNoNum);
|
||||
}
|
||||
Rational const& rat,
|
||||
bool fNegative,
|
||||
bool fDecimal,
|
||||
bool fSciFmt) :
|
||||
m_commands(commands), m_value{ rat }, m_fNegative(fNegative), m_fDecimal(fDecimal), m_fSciFmt(fSciFmt)
|
||||
{}
|
||||
|
||||
const shared_ptr<CalculatorVector<int>> & COpndCommand::GetCommands() const
|
||||
{
|
||||
|
@ -294,19 +282,15 @@ const wstring & COpndCommand::GetToken(wchar_t decimalSymbol)
|
|||
|
||||
wstring COpndCommand::GetString(uint32_t radix, int32_t precision, wchar_t decimalSymbol)
|
||||
{
|
||||
wstring numString{};
|
||||
if (m_hnoNum != nullptr)
|
||||
{
|
||||
numString = NumObjToString(m_hnoNum, radix, eNUMOBJ_FMT::FMT_FLOAT, precision);
|
||||
}
|
||||
PRAT valRat = m_value.ToPRAT();
|
||||
auto result = NumObjToString(valRat, radix, eNUMOBJ_FMT::FMT_FLOAT, precision);
|
||||
destroyrat(valRat);
|
||||
|
||||
return numString;
|
||||
return result;
|
||||
}
|
||||
|
||||
COpndCommand::~COpndCommand()
|
||||
{
|
||||
destroyrat(m_hnoNum);
|
||||
}
|
||||
{}
|
||||
|
||||
void COpndCommand::Accept(_In_ ISerializeCommandVisitor &commandVisitor)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue