merge with master
This commit is contained in:
@@ -179,7 +179,7 @@ bool CalcInput::TryAddDecimalPt()
|
||||
|
||||
if (m_base.IsEmpty())
|
||||
{
|
||||
m_base.value += L"0"; // Add a leading zero
|
||||
m_base.value += L'0'; // Add a leading zero
|
||||
}
|
||||
|
||||
m_decPtIndex = m_base.value.size();
|
||||
@@ -261,6 +261,11 @@ void CalcInput::SetDecimalSymbol(wchar_t decSymbol)
|
||||
}
|
||||
}
|
||||
|
||||
bool CalcInput::IsEmpty()
|
||||
{
|
||||
return m_base.IsEmpty() && !m_hasExponent && m_exponent.IsEmpty() && !m_hasDecimal;
|
||||
}
|
||||
|
||||
wstring CalcInput::ToString(uint32_t radix)
|
||||
{
|
||||
// In theory both the base and exponent could be C_NUM_MAX_DIGITS long.
|
||||
|
@@ -11,14 +11,14 @@ bool IsOpInRange(OpCode op, uint32_t x, uint32_t y)
|
||||
|
||||
bool IsBinOpCode(OpCode opCode)
|
||||
{
|
||||
return IsOpInRange(opCode, IDC_AND, IDC_PWR);
|
||||
return IsOpInRange(opCode, IDC_AND, IDC_PWR) || IsOpInRange(opCode, IDC_BINARYEXTENDEDFIRST, IDC_BINARYEXTENDEDLAST);
|
||||
}
|
||||
|
||||
// WARNING: IDC_SIGN is a special unary op but still this doesn't catch this. Caller has to be aware
|
||||
// of it and catch it themselves or not needing this
|
||||
bool IsUnaryOpCode(OpCode opCode)
|
||||
{
|
||||
return IsOpInRange(opCode, IDC_UNARYFIRST, IDC_UNARYLAST);
|
||||
return (IsOpInRange(opCode, IDC_UNARYFIRST, IDC_UNARYLAST) || IsOpInRange(opCode, IDC_UNARYEXTENDEDFIRST, IDC_UNARYEXTENDEDLAST));
|
||||
}
|
||||
|
||||
bool IsDigitOpCode(OpCode opCode)
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "Header Files/CalcEngine.h"
|
||||
#include "Command.h"
|
||||
#include "CalculatorVector.h"
|
||||
#include "ExpressionCommand.h"
|
||||
|
||||
constexpr int ASCII_0 = 48;
|
||||
@@ -13,14 +12,19 @@ using namespace CalcEngine;
|
||||
|
||||
namespace
|
||||
{
|
||||
void IFT(ResultCode hr)
|
||||
template <typename T>
|
||||
static void Truncate(vector<T>& v, unsigned int index)
|
||||
{
|
||||
if (FAILED(hr))
|
||||
if (index >= v.size())
|
||||
{
|
||||
throw hr;
|
||||
throw E_BOUNDS;
|
||||
}
|
||||
|
||||
auto startIter = v.begin() + index;
|
||||
v.erase(startIter, v.end());
|
||||
}
|
||||
}
|
||||
|
||||
void CHistoryCollector::ReinitHistory()
|
||||
{
|
||||
m_lastOpStartIndex = -1;
|
||||
@@ -29,11 +33,11 @@ void CHistoryCollector::ReinitHistory()
|
||||
m_bLastOpndBrace = false;
|
||||
if (m_spTokens != nullptr)
|
||||
{
|
||||
m_spTokens->Clear();
|
||||
m_spTokens->clear();
|
||||
}
|
||||
if (m_spCommands != nullptr)
|
||||
{
|
||||
m_spCommands->Clear();
|
||||
m_spCommands->clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,13 +59,13 @@ CHistoryCollector::~CHistoryCollector()
|
||||
|
||||
if (m_spTokens != nullptr)
|
||||
{
|
||||
m_spTokens->Clear();
|
||||
m_spTokens->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void CHistoryCollector::AddOpndToHistory(wstring_view numStr, Rational const& rat, bool fRepetition)
|
||||
{
|
||||
std::shared_ptr<CalculatorVector<int>> commands = std::make_shared<CalculatorVector<int>>();
|
||||
std::shared_ptr<std::vector<int>> commands = std::make_shared<vector<int>>();
|
||||
// Check for negate
|
||||
bool fNegative = (numStr[0] == L'-');
|
||||
bool fSciFmt = false;
|
||||
@@ -71,7 +75,7 @@ void CHistoryCollector::AddOpndToHistory(wstring_view numStr, Rational const& ra
|
||||
{
|
||||
if (numStr[i] == m_decimalSymbol)
|
||||
{
|
||||
IFT(commands->Append(IDC_PNT));
|
||||
commands->push_back(IDC_PNT);
|
||||
if (!fSciFmt)
|
||||
{
|
||||
fDecimal = true;
|
||||
@@ -79,12 +83,12 @@ void CHistoryCollector::AddOpndToHistory(wstring_view numStr, Rational const& ra
|
||||
}
|
||||
else if (numStr[i] == L'e')
|
||||
{
|
||||
IFT(commands->Append(IDC_EXP));
|
||||
commands->push_back(IDC_EXP);
|
||||
fSciFmt = true;
|
||||
}
|
||||
else if (numStr[i] == L'-')
|
||||
{
|
||||
IFT(commands->Append(IDC_SIGN));
|
||||
commands->push_back(IDC_SIGN);
|
||||
}
|
||||
else if (numStr[i] == L'+')
|
||||
{
|
||||
@@ -95,7 +99,7 @@ void CHistoryCollector::AddOpndToHistory(wstring_view numStr, Rational const& ra
|
||||
{
|
||||
int num = static_cast<int>(numStr[i]) - ASCII_0;
|
||||
num += IDC_0;
|
||||
IFT(commands->Append(num));
|
||||
commands->push_back(num);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,12 +124,12 @@ void CHistoryCollector::RemoveLastOpndFromHistory()
|
||||
// This will not restore the m_lastBinOpStartIndex, as it isn't possible to remove that also later
|
||||
}
|
||||
|
||||
void CHistoryCollector::AddBinOpToHistory(int nOpCode, bool fNoRepetition)
|
||||
void CHistoryCollector::AddBinOpToHistory(int nOpCode, bool isIntegerMode, bool fNoRepetition)
|
||||
{
|
||||
int iCommandEnd = AddCommand(std::make_shared<CBinaryCommand>(nOpCode));
|
||||
m_lastBinOpStartIndex = IchAddSzToEquationSz(L" ", -1);
|
||||
|
||||
IchAddSzToEquationSz(CCalcEngine::OpCodeToString(nOpCode), iCommandEnd);
|
||||
IchAddSzToEquationSz(CCalcEngine::OpCodeToBinaryString(nOpCode, isIntegerMode), iCommandEnd);
|
||||
IchAddSzToEquationSz(L" ", -1);
|
||||
|
||||
if (fNoRepetition)
|
||||
@@ -138,14 +142,14 @@ void CHistoryCollector::AddBinOpToHistory(int nOpCode, bool fNoRepetition)
|
||||
// This is expected to be called when a binary op in the last say 1+2+ is changing to another one say 1+2* (+ changed to *)
|
||||
// It needs to know by this change a Precedence inversion happened. i.e. previous op was lower or equal to its previous op, but the new
|
||||
// one isn't. (Eg. 1*2* to 1*2^). It can add explicit brackets to ensure the precedence is inverted. (Eg. (1*2) ^)
|
||||
void CHistoryCollector::ChangeLastBinOp(int nOpCode, bool fPrecInvToHigher)
|
||||
void CHistoryCollector::ChangeLastBinOp(int nOpCode, bool fPrecInvToHigher, bool isIntgerMode)
|
||||
{
|
||||
TruncateEquationSzFromIch(m_lastBinOpStartIndex);
|
||||
if (fPrecInvToHigher)
|
||||
{
|
||||
EnclosePrecInversionBrackets();
|
||||
}
|
||||
AddBinOpToHistory(nOpCode);
|
||||
AddBinOpToHistory(nOpCode, isIntgerMode);
|
||||
}
|
||||
|
||||
void CHistoryCollector::PushLastOpndStart(int ichOpndStart)
|
||||
@@ -266,6 +270,30 @@ void CHistoryCollector::AddUnaryOpToHistory(int nOpCode, bool fInv, ANGLE_TYPE a
|
||||
command = fInv ? static_cast<int>(CalculationManager::Command::CommandATANH) : IDC_TANH;
|
||||
spExpressionCommand = std::make_shared<CUnaryCommand>(command);
|
||||
break;
|
||||
case IDC_SEC:
|
||||
command = fInv ? static_cast<int>(CalculationManager::Command::CommandASEC) : IDC_SEC;
|
||||
spExpressionCommand = std::make_shared<CUnaryCommand>(static_cast<int>(angleOpCode), command);
|
||||
break;
|
||||
case IDC_CSC:
|
||||
command = fInv ? static_cast<int>(CalculationManager::Command::CommandACSC) : IDC_CSC;
|
||||
spExpressionCommand = std::make_shared<CUnaryCommand>(static_cast<int>(angleOpCode), command);
|
||||
break;
|
||||
case IDC_COT:
|
||||
command = fInv ? static_cast<int>(CalculationManager::Command::CommandACOT) : IDC_COT;
|
||||
spExpressionCommand = std::make_shared<CUnaryCommand>(static_cast<int>(angleOpCode), command);
|
||||
break;
|
||||
case IDC_SECH:
|
||||
command = fInv ? static_cast<int>(CalculationManager::Command::CommandASECH) : IDC_SECH;
|
||||
spExpressionCommand = std::make_shared<CUnaryCommand>(command);
|
||||
break;
|
||||
case IDC_CSCH:
|
||||
command = fInv ? static_cast<int>(CalculationManager::Command::CommandACSCH) : IDC_CSCH;
|
||||
spExpressionCommand = std::make_shared<CUnaryCommand>(command);
|
||||
break;
|
||||
case IDC_COTH:
|
||||
command = fInv ? static_cast<int>(CalculationManager::Command::CommandACOTH) : IDC_COTH;
|
||||
spExpressionCommand = std::make_shared<CUnaryCommand>(command);
|
||||
break;
|
||||
case IDC_LN:
|
||||
command = fInv ? static_cast<int>(CalculationManager::Command::CommandPOWE) : IDC_LN;
|
||||
spExpressionCommand = std::make_shared<CUnaryCommand>(command);
|
||||
@@ -301,12 +329,6 @@ void CHistoryCollector::AddUnaryOpToHistory(int nOpCode, bool fInv, ANGLE_TYPE a
|
||||
// history of equations
|
||||
void CHistoryCollector::CompleteHistoryLine(wstring_view numStr)
|
||||
{
|
||||
if (nullptr != m_pCalcDisplay)
|
||||
{
|
||||
m_pCalcDisplay->SetExpressionDisplay(
|
||||
std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>(), std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>());
|
||||
}
|
||||
|
||||
if (nullptr != m_pHistoryDisplay)
|
||||
{
|
||||
unsigned int addedItemIndex = m_pHistoryDisplay->AddToHistory(m_spTokens, m_spCommands, numStr);
|
||||
@@ -319,6 +341,16 @@ void CHistoryCollector::CompleteHistoryLine(wstring_view numStr)
|
||||
ReinitHistory();
|
||||
}
|
||||
|
||||
void CHistoryCollector::CompleteEquation(std::wstring_view numStr)
|
||||
{
|
||||
// Add only '=' token and not add EQU command, because
|
||||
// EQU command breaks loading from history (it duplicate history entries).
|
||||
IchAddSzToEquationSz(CCalcEngine::OpCodeToString(IDC_EQU), -1);
|
||||
|
||||
SetExpressionDisplay();
|
||||
CompleteHistoryLine(numStr);
|
||||
}
|
||||
|
||||
void CHistoryCollector::ClearHistoryLine(wstring_view errStr)
|
||||
{
|
||||
if (errStr.empty()) // in case of error let the display stay as it is
|
||||
@@ -326,7 +358,7 @@ void CHistoryCollector::ClearHistoryLine(wstring_view errStr)
|
||||
if (nullptr != m_pCalcDisplay)
|
||||
{
|
||||
m_pCalcDisplay->SetExpressionDisplay(
|
||||
std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>(), std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>());
|
||||
std::make_shared<std::vector<std::pair<std::wstring, int>>>(), std::make_shared<std::vector<std::shared_ptr<IExpressionCommand>>>());
|
||||
}
|
||||
m_iCurLineHistStart = -1; // It will get recomputed at the first Opnd
|
||||
ReinitHistory();
|
||||
@@ -339,26 +371,17 @@ int CHistoryCollector::IchAddSzToEquationSz(wstring_view str, int icommandIndex)
|
||||
{
|
||||
if (m_spTokens == nullptr)
|
||||
{
|
||||
m_spTokens = std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>();
|
||||
m_spTokens = std::make_shared<std::vector<std::pair<std::wstring, int>>>();
|
||||
}
|
||||
|
||||
if (FAILED(m_spTokens->Append(std::make_pair(wstring(str), icommandIndex))))
|
||||
{
|
||||
throw(CALC_E_OUTOFMEMORY);
|
||||
}
|
||||
|
||||
unsigned int nTokens;
|
||||
m_spTokens->GetSize(&nTokens);
|
||||
return nTokens - 1;
|
||||
m_spTokens->push_back(std::pair(wstring(str), icommandIndex));
|
||||
return static_cast<int>(m_spTokens->size() - 1);
|
||||
}
|
||||
|
||||
// Inserts a given string into the global m_pszEquation at the given index ich taking care of reallocations etc.
|
||||
void CHistoryCollector::InsertSzInEquationSz(wstring_view str, int icommandIndex, int ich)
|
||||
{
|
||||
if (FAILED(m_spTokens->InsertAt(ich, std::make_pair(wstring(str), icommandIndex))))
|
||||
{
|
||||
throw(CALC_E_OUTOFMEMORY);
|
||||
}
|
||||
m_spTokens->emplace(m_spTokens->begin() + ich, wstring(str), icommandIndex);
|
||||
}
|
||||
|
||||
// Chops off the current equation string from the given index
|
||||
@@ -366,25 +389,23 @@ void CHistoryCollector::TruncateEquationSzFromIch(int ich)
|
||||
{
|
||||
// Truncate commands
|
||||
int minIdx = -1;
|
||||
unsigned int nTokens = 0;
|
||||
std::pair<std::wstring, int> currentPair;
|
||||
m_spTokens->GetSize(&nTokens);
|
||||
unsigned int nTokens = static_cast<unsigned int>(m_spTokens->size());
|
||||
|
||||
for (unsigned int i = ich; i < nTokens; i++)
|
||||
{
|
||||
IFT(m_spTokens->GetAt(i, ¤tPair));
|
||||
const auto& currentPair = (*m_spTokens)[i];
|
||||
int curTokenId = currentPair.second;
|
||||
if (curTokenId != -1)
|
||||
{
|
||||
if ((minIdx != -1) || (curTokenId < minIdx))
|
||||
{
|
||||
minIdx = curTokenId;
|
||||
IFT(m_spCommands->Truncate(minIdx));
|
||||
Truncate(*m_spCommands, minIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IFT(m_spTokens->Truncate(ich));
|
||||
Truncate(*m_spTokens, ich);
|
||||
}
|
||||
|
||||
// Adds the m_pszEquation into the running history text
|
||||
@@ -400,17 +421,11 @@ int CHistoryCollector::AddCommand(_In_ const std::shared_ptr<IExpressionCommand>
|
||||
{
|
||||
if (m_spCommands == nullptr)
|
||||
{
|
||||
m_spCommands = std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>();
|
||||
m_spCommands = std::make_shared<std::vector<std::shared_ptr<IExpressionCommand>>>();
|
||||
}
|
||||
|
||||
if (FAILED(m_spCommands->Append(spCommand)))
|
||||
{
|
||||
throw(CALC_E_OUTOFMEMORY);
|
||||
}
|
||||
|
||||
unsigned int nCommands = 0;
|
||||
m_spCommands->GetSize(&nCommands);
|
||||
return nCommands - 1;
|
||||
m_spCommands->push_back(spCommand);
|
||||
return static_cast<int>(m_spCommands->size() - 1);
|
||||
}
|
||||
|
||||
// To Update the operands in the Expression according to the current Radix
|
||||
@@ -421,30 +436,25 @@ void CHistoryCollector::UpdateHistoryExpression(uint32_t radix, int32_t precisio
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int size;
|
||||
IFT(m_spTokens->GetSize(&size));
|
||||
|
||||
for (unsigned int i = 0; i < size; ++i)
|
||||
for (auto& token : *m_spTokens)
|
||||
{
|
||||
std::pair<std::wstring, int> token;
|
||||
IFT(m_spTokens->GetAt(i, &token));
|
||||
int commandPosition = token.second;
|
||||
if (commandPosition != -1)
|
||||
{
|
||||
std::shared_ptr<IExpressionCommand> expCommand;
|
||||
IFT(m_spCommands->GetAt(commandPosition, &expCommand));
|
||||
const std::shared_ptr<IExpressionCommand>& expCommand = m_spCommands->at(commandPosition);
|
||||
|
||||
if (expCommand != nullptr && CalculationManager::CommandType::OperandCommand == expCommand->GetCommandType())
|
||||
{
|
||||
std::shared_ptr<COpndCommand> opndCommand = std::static_pointer_cast<COpndCommand>(expCommand);
|
||||
const std::shared_ptr<COpndCommand>& opndCommand = std::static_pointer_cast<COpndCommand>(expCommand);
|
||||
if (opndCommand != nullptr)
|
||||
{
|
||||
token.first = opndCommand->GetString(radix, precision);
|
||||
IFT(m_spTokens->SetAt(i, token));
|
||||
opndCommand->SetCommands(GetOperandCommandsFromString(token.first));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetExpressionDisplay();
|
||||
}
|
||||
|
||||
@@ -454,9 +464,9 @@ void CHistoryCollector::SetDecimalSymbol(wchar_t decimalSymbol)
|
||||
}
|
||||
|
||||
// Update the commands corresponding to the passed string Number
|
||||
std::shared_ptr<CalculatorVector<int>> CHistoryCollector::GetOperandCommandsFromString(wstring_view numStr)
|
||||
std::shared_ptr<std::vector<int>> CHistoryCollector::GetOperandCommandsFromString(wstring_view numStr)
|
||||
{
|
||||
std::shared_ptr<CalculatorVector<int>> commands = std::make_shared<CalculatorVector<int>>();
|
||||
std::shared_ptr<std::vector<int>> commands = std::make_shared<std::vector<int>>();
|
||||
// Check for negate
|
||||
bool fNegative = (numStr[0] == L'-');
|
||||
|
||||
@@ -464,15 +474,15 @@ std::shared_ptr<CalculatorVector<int>> CHistoryCollector::GetOperandCommandsFrom
|
||||
{
|
||||
if (numStr[i] == m_decimalSymbol)
|
||||
{
|
||||
IFT(commands->Append(IDC_PNT));
|
||||
commands->push_back(IDC_PNT);
|
||||
}
|
||||
else if (numStr[i] == L'e')
|
||||
{
|
||||
IFT(commands->Append(IDC_EXP));
|
||||
commands->push_back(IDC_EXP);
|
||||
}
|
||||
else if (numStr[i] == L'-')
|
||||
{
|
||||
IFT(commands->Append(IDC_SIGN));
|
||||
commands->push_back(IDC_SIGN);
|
||||
}
|
||||
else if (numStr[i] == L'+')
|
||||
{
|
||||
@@ -483,14 +493,14 @@ std::shared_ptr<CalculatorVector<int>> CHistoryCollector::GetOperandCommandsFrom
|
||||
{
|
||||
int num = static_cast<int>(numStr[i]) - ASCII_0;
|
||||
num += IDC_0;
|
||||
IFT(commands->Append(num));
|
||||
commands->push_back(num);
|
||||
}
|
||||
}
|
||||
|
||||
// If the number is negative, append a sign command at the end.
|
||||
if (fNegative)
|
||||
{
|
||||
IFT(commands->Append(IDC_SIGN));
|
||||
commands->push_back(IDC_SIGN);
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
|
@@ -24,17 +24,16 @@ static constexpr wstring_view DEFAULT_NUMBER_STR = L"0";
|
||||
// Read strings for keys, errors, trig types, etc.
|
||||
// These will be copied from the resources to local memory.
|
||||
|
||||
unordered_map<wstring, wstring> CCalcEngine::s_engineStrings;
|
||||
unordered_map<wstring_view, wstring> CCalcEngine::s_engineStrings;
|
||||
|
||||
void CCalcEngine::LoadEngineStrings(CalculationManager::IResourceProvider& resourceProvider)
|
||||
{
|
||||
for (const auto& sid : g_sids)
|
||||
{
|
||||
auto locKey = wstring{ sid };
|
||||
auto locString = resourceProvider.GetCEngineString(locKey);
|
||||
auto locString = resourceProvider.GetCEngineString(sid);
|
||||
if (!locString.empty())
|
||||
{
|
||||
s_engineStrings[locKey] = locString;
|
||||
s_engineStrings[sid] = locString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include <string>
|
||||
#include "Header Files/CalcEngine.h"
|
||||
#include "Header Files/CalcUtils.h"
|
||||
#include "NumberFormattingUtils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace CalcEngine;
|
||||
@@ -28,8 +29,13 @@ namespace
|
||||
// 0 is returned. Higher the number, higher the precedence of the operator.
|
||||
int NPrecedenceOfOp(int nopCode)
|
||||
{
|
||||
static uint8_t rgbPrec[] = { 0, 0, IDC_OR, 0, IDC_XOR, 0, IDC_AND, 1, IDC_ADD, 2, IDC_SUB, 2, IDC_RSHF,
|
||||
3, IDC_LSHF, 3, IDC_MOD, 3, IDC_DIV, 3, IDC_MUL, 3, IDC_PWR, 4, IDC_ROOT, 4 };
|
||||
static uint16_t rgbPrec[] = {
|
||||
0,0, IDC_OR,0, IDC_XOR,0,
|
||||
IDC_AND,1, IDC_NAND,1, IDC_NOR,1,
|
||||
IDC_ADD,2, IDC_SUB,2,
|
||||
IDC_RSHF,3, IDC_LSHF,3, IDC_RSHFL,3,
|
||||
IDC_MOD,3, IDC_DIV,3, IDC_MUL,3,
|
||||
IDC_PWR,4, IDC_ROOT,4, IDC_LOGBASEX,4 };
|
||||
unsigned int iPrec;
|
||||
|
||||
iPrec = 0;
|
||||
@@ -76,6 +82,15 @@ void CCalcEngine::ClearTemporaryValues()
|
||||
m_bError = false;
|
||||
}
|
||||
|
||||
void CCalcEngine::ClearDisplay()
|
||||
{
|
||||
if (nullptr != m_pCalcDisplay)
|
||||
{
|
||||
m_pCalcDisplay->SetExpressionDisplay(
|
||||
make_shared<vector<pair<wstring, int>>>(), make_shared<vector<shared_ptr<IExpressionCommand>>>());
|
||||
}
|
||||
}
|
||||
|
||||
void CCalcEngine::ProcessCommand(OpCode wParam)
|
||||
{
|
||||
if (wParam == IDC_SET_RESULT)
|
||||
@@ -103,6 +118,12 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
m_nTempCom = (int)wParam;
|
||||
}
|
||||
|
||||
// Clear expression shown after = sign, when user do any action.
|
||||
if (!m_bNoPrevEqu)
|
||||
{
|
||||
ClearDisplay();
|
||||
}
|
||||
|
||||
if (m_bError)
|
||||
{
|
||||
if (wParam == IDC_CLEAR)
|
||||
@@ -124,9 +145,18 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
// Toggle Record/Display mode if appropriate.
|
||||
if (m_bRecord)
|
||||
{
|
||||
if (IsOpInRange(wParam, IDC_AND, IDC_MMINUS) || IsOpInRange(wParam, IDC_OPENP, IDC_CLOSEP) || IsOpInRange(wParam, IDM_HEX, IDM_BIN)
|
||||
|| IsOpInRange(wParam, IDM_QWORD, IDM_BYTE) || IsOpInRange(wParam, IDM_DEG, IDM_GRAD)
|
||||
|| IsOpInRange(wParam, IDC_BINEDITSTART, IDC_BINEDITSTART + 63) || (IDC_INV == wParam) || (IDC_SIGN == wParam && 10 != m_radix))
|
||||
if (IsBinOpCode(wParam) ||
|
||||
IsUnaryOpCode(wParam) ||
|
||||
IsOpInRange(wParam, IDC_FE, IDC_MMINUS) ||
|
||||
IsOpInRange(wParam, IDC_OPENP, IDC_CLOSEP) ||
|
||||
IsOpInRange(wParam, IDM_HEX, IDM_BIN) ||
|
||||
IsOpInRange(wParam, IDM_QWORD, IDM_BYTE) ||
|
||||
IsOpInRange(wParam, IDM_DEG, IDM_GRAD) ||
|
||||
IsOpInRange(wParam, IDC_BINEDITSTART, IDC_BINEDITEND) ||
|
||||
(IDC_INV == wParam) ||
|
||||
(IDC_SIGN == wParam && 10 != m_radix) ||
|
||||
(IDC_RAND == wParam) ||
|
||||
(IDC_EULER == wParam))
|
||||
{
|
||||
m_bRecord = false;
|
||||
m_currentVal = m_input.ToRational(m_radix, m_precision);
|
||||
@@ -193,7 +223,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
m_nPrevOpCode = 0; // Once the precedence inversion has put additional brackets, its no longer required
|
||||
}
|
||||
}
|
||||
m_HistoryCollector.ChangeLastBinOp(m_nOpCode, fPrecInvToHigher);
|
||||
m_HistoryCollector.ChangeLastBinOp(m_nOpCode, fPrecInvToHigher, m_fIntegerMode);
|
||||
DisplayAnnounceBinaryOperator();
|
||||
return;
|
||||
}
|
||||
@@ -270,10 +300,9 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
}
|
||||
|
||||
DisplayAnnounceBinaryOperator();
|
||||
|
||||
m_lastVal = m_currentVal;
|
||||
m_nOpCode = (int)wParam;
|
||||
m_HistoryCollector.AddBinOpToHistory(m_nOpCode);
|
||||
m_HistoryCollector.AddBinOpToHistory(m_nOpCode, m_fIntegerMode);
|
||||
m_bNoPrevEqu = m_bChangeOp = true;
|
||||
return;
|
||||
}
|
||||
@@ -303,7 +332,8 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
m_HistoryCollector.AddUnaryOpToHistory((int)wParam, m_bInv, m_angletype);
|
||||
}
|
||||
|
||||
if ((wParam == IDC_SIN) || (wParam == IDC_COS) || (wParam == IDC_TAN) || (wParam == IDC_SINH) || (wParam == IDC_COSH) || (wParam == IDC_TANH))
|
||||
if ((wParam == IDC_SIN) || (wParam == IDC_COS) || (wParam == IDC_TAN) || (wParam == IDC_SINH) || (wParam == IDC_COSH) || (wParam == IDC_TANH)
|
||||
|| (wParam == IDC_SEC) || (wParam == IDC_CSC) || (wParam == IDC_COT) || (wParam == IDC_SECH) || (wParam == IDC_CSCH) || (wParam == IDC_COTH))
|
||||
{
|
||||
if (IsCurrentTooBigForTrig())
|
||||
{
|
||||
@@ -330,9 +360,13 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
/* reset the m_bInv flag and indicators if it is set
|
||||
and have been used */
|
||||
|
||||
if (m_bInv
|
||||
&& ((wParam == IDC_CHOP) || (wParam == IDC_SIN) || (wParam == IDC_COS) || (wParam == IDC_TAN) || (wParam == IDC_LN) || (wParam == IDC_DMS)
|
||||
|| (wParam == IDC_DEGREES) || (wParam == IDC_SINH) || (wParam == IDC_COSH) || (wParam == IDC_TANH)))
|
||||
if (m_bInv &&
|
||||
((wParam == IDC_CHOP) || (wParam == IDC_SIN) || (wParam == IDC_COS) ||
|
||||
(wParam == IDC_TAN) || (wParam == IDC_LN) || (wParam == IDC_DMS) ||
|
||||
(wParam == IDC_DEGREES) || (wParam == IDC_SINH) || (wParam == IDC_COSH) ||
|
||||
(wParam == IDC_TANH) || (wParam == IDC_SEC) || (wParam == IDC_CSC) ||
|
||||
(wParam == IDC_COT) || (wParam == IDC_SECH) || (wParam == IDC_CSCH) ||
|
||||
(wParam == IDC_COTH)))
|
||||
{
|
||||
m_bInv = false;
|
||||
}
|
||||
@@ -341,10 +375,10 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
}
|
||||
|
||||
// Tiny binary edit windows clicked. Toggle that bit and update display
|
||||
if (IsOpInRange(wParam, IDC_BINEDITSTART, IDC_BINEDITSTART + 63))
|
||||
if (IsOpInRange(wParam, IDC_BINEDITSTART, IDC_BINEDITEND))
|
||||
{
|
||||
// Same reasoning as for unary operators. We need to seed it previous number
|
||||
if (m_nLastCom >= IDC_AND && m_nLastCom <= IDC_PWR)
|
||||
if (IsBinOpCode(m_nLastCom))
|
||||
{
|
||||
m_currentVal = m_lastVal;
|
||||
}
|
||||
@@ -377,14 +411,14 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
m_precedenceOpCount = m_nTempCom = m_nLastCom = m_nOpCode = 0;
|
||||
m_nPrevOpCode = 0;
|
||||
m_bNoPrevEqu = true;
|
||||
m_carryBit = 0;
|
||||
|
||||
/* clear the parenthesis status box indicator, this will not be
|
||||
cleared for CENTR */
|
||||
if (nullptr != m_pCalcDisplay)
|
||||
{
|
||||
m_pCalcDisplay->SetParenthesisNumber(0);
|
||||
m_pCalcDisplay->SetExpressionDisplay(
|
||||
make_shared<CalculatorVector<pair<wstring, int>>>(), make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>());
|
||||
ClearDisplay();
|
||||
}
|
||||
|
||||
m_HistoryCollector.ClearHistoryLine(wstring());
|
||||
@@ -474,12 +508,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
if (!m_bError)
|
||||
{
|
||||
wstring groupedString = GroupDigitsPerRadix(m_numberString, m_radix);
|
||||
m_HistoryCollector.CompleteHistoryLine(groupedString);
|
||||
if (nullptr != m_pCalcDisplay)
|
||||
{
|
||||
m_pCalcDisplay->SetExpressionDisplay(
|
||||
make_shared<CalculatorVector<pair<wstring, int>>>(), make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>());
|
||||
}
|
||||
m_HistoryCollector.CompleteEquation(groupedString);
|
||||
}
|
||||
|
||||
m_bChangeOp = false;
|
||||
@@ -700,7 +729,6 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
case IDC_MCLEAR:
|
||||
m_memoryValue = make_unique<Rational>(wParam == IDC_STORE ? TruncateNumForIntMath(m_currentVal) : 0);
|
||||
break;
|
||||
|
||||
case IDC_PI:
|
||||
if (!m_fIntegerMode)
|
||||
{
|
||||
@@ -713,7 +741,43 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
}
|
||||
HandleErrorCommand(wParam);
|
||||
break;
|
||||
case IDC_RAND:
|
||||
if (!m_fIntegerMode)
|
||||
{
|
||||
CheckAndAddLastBinOpToHistory(); // rand is like entering the number
|
||||
|
||||
wstringstream str;
|
||||
str << fixed << setprecision(m_precision) << GenerateRandomNumber();
|
||||
|
||||
auto rat = StringToRat(false, str.str(), false, L"", m_radix, m_precision);
|
||||
if (rat != nullptr)
|
||||
{
|
||||
m_currentVal = Rational{ rat };
|
||||
}
|
||||
else
|
||||
{
|
||||
m_currentVal = Rational{ 0 };
|
||||
}
|
||||
destroyrat(rat);
|
||||
|
||||
DisplayNum();
|
||||
m_bInv = false;
|
||||
break;
|
||||
}
|
||||
HandleErrorCommand(wParam);
|
||||
break;
|
||||
case IDC_EULER:
|
||||
if (!m_fIntegerMode)
|
||||
{
|
||||
CheckAndAddLastBinOpToHistory(); // e is like entering the number
|
||||
m_currentVal = Rational{ rat_exp };
|
||||
|
||||
DisplayNum();
|
||||
m_bInv = false;
|
||||
break;
|
||||
}
|
||||
HandleErrorCommand(wParam);
|
||||
break;
|
||||
case IDC_FE:
|
||||
// Toggle exponential notation display.
|
||||
m_nFE = NUMOBJ_FMT(!(int)m_nFE);
|
||||
@@ -761,7 +825,7 @@ void CCalcEngine::ResolveHighestPrecedenceOperation()
|
||||
{
|
||||
m_currentVal = m_holdVal;
|
||||
DisplayNum(); // to update the m_numberString
|
||||
m_HistoryCollector.AddBinOpToHistory(m_nOpCode, false);
|
||||
m_HistoryCollector.AddBinOpToHistory(m_nOpCode, m_fIntegerMode, false);
|
||||
m_HistoryCollector.AddOpndToHistory(m_numberString, m_currentVal); // Adding the repeated last op to history
|
||||
}
|
||||
|
||||
@@ -863,11 +927,14 @@ struct FunctionNameElement
|
||||
wstring gradString;
|
||||
wstring inverseGradString; // Will fall back to gradString if empty
|
||||
|
||||
wstring programmerModeString;
|
||||
|
||||
bool hasAngleStrings = ((!radString.empty()) || (!inverseRadString.empty()) || (!gradString.empty()) || (!inverseGradString.empty()));
|
||||
};
|
||||
|
||||
// Table for each unary operator
|
||||
static const std::unordered_map<int, FunctionNameElement> unaryOperatorStringTable = {
|
||||
static const std::unordered_map<int, FunctionNameElement> operatorStringTable =
|
||||
{
|
||||
{ IDC_CHOP, { L"", SIDS_FRAC } },
|
||||
|
||||
{ IDC_SIN, { SIDS_SIND, SIDS_ASIND, SIDS_SINR, SIDS_ASINR, SIDS_SING, SIDS_ASING } },
|
||||
@@ -878,6 +945,14 @@ static const std::unordered_map<int, FunctionNameElement> unaryOperatorStringTab
|
||||
{ IDC_COSH, { L"", SIDS_ACOSH } },
|
||||
{ IDC_TANH, { L"", SIDS_ATANH } },
|
||||
|
||||
{ IDC_SEC, { SIDS_SECD, SIDS_ASECD, SIDS_SECR, SIDS_ASECR, SIDS_SECG, SIDS_ASECG } },
|
||||
{ IDC_CSC, { SIDS_CSCD, SIDS_ACSCD, SIDS_CSCR, SIDS_ACSCR, SIDS_CSCG, SIDS_ACSCG } },
|
||||
{ IDC_COT, { SIDS_COTD, SIDS_ACOTD, SIDS_COTR, SIDS_ACOTR, SIDS_COTG, SIDS_ACOTG } },
|
||||
|
||||
{ IDC_SECH, { SIDS_SECH, SIDS_ASECH } },
|
||||
{ IDC_CSCH, { SIDS_CSCH, SIDS_ACSCH } },
|
||||
{ IDC_COTH, { SIDS_COTH, SIDS_ACOTH } },
|
||||
|
||||
{ IDC_LN, { L"", SIDS_POWE } },
|
||||
{ IDC_SQR, { SIDS_SQR } },
|
||||
{ IDC_CUB, { SIDS_CUBE } },
|
||||
@@ -885,7 +960,19 @@ static const std::unordered_map<int, FunctionNameElement> unaryOperatorStringTab
|
||||
{ IDC_REC, { SIDS_RECIPROC } },
|
||||
{ IDC_DMS, { L"", SIDS_DEGREES } },
|
||||
{ IDC_SIGN, { SIDS_NEGATE } },
|
||||
{ IDC_DEGREES, { SIDS_DEGREES } }
|
||||
{ IDC_DEGREES, { SIDS_DEGREES } },
|
||||
{ IDC_POW2, { SIDS_TWOPOWX } },
|
||||
{ IDC_LOGBASEX, { SIDS_LOGBASEX } },
|
||||
{ IDC_ABS, { SIDS_ABS } },
|
||||
{ IDC_CEIL, { SIDS_CEIL } },
|
||||
{ IDC_FLOOR, { SIDS_FLOOR } },
|
||||
{ IDC_NAND, { SIDS_NAND } },
|
||||
{ IDC_NOR, { SIDS_NOR } },
|
||||
{ IDC_RSHFL, { SIDS_RSH } },
|
||||
{ IDC_RORC, { SIDS_ROR } },
|
||||
{ IDC_ROLC, { SIDS_ROL } },
|
||||
{ IDC_CUBEROOT, {SIDS_CUBEROOT} },
|
||||
{ IDC_MOD, {SIDS_MOD, L"", L"", L"", L"", L"", SIDS_PROGRAMMER_MOD} },
|
||||
};
|
||||
|
||||
wstring_view CCalcEngine::OpCodeToUnaryString(int nOpCode, bool fInv, ANGLE_TYPE angletype)
|
||||
@@ -893,7 +980,7 @@ wstring_view CCalcEngine::OpCodeToUnaryString(int nOpCode, bool fInv, ANGLE_TYPE
|
||||
// Try to lookup the ID in the UFNE table
|
||||
wstring ids = L"";
|
||||
|
||||
if (auto pair = unaryOperatorStringTable.find(nOpCode); pair != unaryOperatorStringTable.end())
|
||||
if (auto pair = operatorStringTable.find(nOpCode); pair != operatorStringTable.end())
|
||||
{
|
||||
const FunctionNameElement& element = pair->second;
|
||||
if (!element.hasAngleStrings || ANGLE_DEG == angletype)
|
||||
@@ -941,6 +1028,32 @@ wstring_view CCalcEngine::OpCodeToUnaryString(int nOpCode, bool fInv, ANGLE_TYPE
|
||||
return OpCodeToString(nOpCode);
|
||||
}
|
||||
|
||||
wstring_view CCalcEngine::OpCodeToBinaryString(int nOpCode, bool isIntegerMode)
|
||||
{
|
||||
// Try to lookup the ID in the UFNE table
|
||||
wstring ids = L"";
|
||||
|
||||
if (auto pair = operatorStringTable.find(nOpCode); pair != operatorStringTable.end())
|
||||
{
|
||||
if (isIntegerMode && !pair->second.programmerModeString.empty())
|
||||
{
|
||||
ids = pair->second.programmerModeString;
|
||||
}
|
||||
else
|
||||
{
|
||||
ids = pair->second.degreeString;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ids.empty())
|
||||
{
|
||||
return GetString(ids);
|
||||
}
|
||||
|
||||
// If we didn't find an ID in the table, use the op code.
|
||||
return OpCodeToString(nOpCode);
|
||||
}
|
||||
|
||||
bool CCalcEngine::IsCurrentTooBigForTrig()
|
||||
{
|
||||
return m_currentVal >= m_maxTrigonometricNum;
|
||||
@@ -1007,3 +1120,14 @@ wstring CCalcEngine::GetStringForDisplay(Rational const& rat, uint32_t radix)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
double CCalcEngine::GenerateRandomNumber()
|
||||
{
|
||||
if (m_randomGeneratorEngine == nullptr)
|
||||
{
|
||||
random_device rd;
|
||||
m_randomGeneratorEngine = std::make_unique<std::mt19937>(rd());
|
||||
m_distr = std::make_unique<std::uniform_real_distribution<>>(0, 1);
|
||||
}
|
||||
return (*m_distr.get())(*m_randomGeneratorEngine.get());
|
||||
}
|
||||
|
@@ -46,8 +46,8 @@ CalcEngine::Rational CCalcEngine::SciCalcFunctions(CalcEngine::Rational const& r
|
||||
}
|
||||
break;
|
||||
|
||||
// Rotate Left with hi bit wrapped over to lo bit
|
||||
case IDC_ROL:
|
||||
case IDC_ROLC:
|
||||
if (m_fIntegerMode)
|
||||
{
|
||||
result = Integer(rat);
|
||||
@@ -55,14 +55,23 @@ CalcEngine::Rational CCalcEngine::SciCalcFunctions(CalcEngine::Rational const& r
|
||||
uint64_t w64Bits = result.ToUInt64_t();
|
||||
uint64_t msb = (w64Bits >> (m_dwWordBitWidth - 1)) & 1;
|
||||
w64Bits <<= 1; // LShift by 1
|
||||
w64Bits |= msb; // Set the prev Msb as the current Lsb
|
||||
|
||||
if (op == IDC_ROL)
|
||||
{
|
||||
w64Bits |= msb; // Set the prev Msb as the current Lsb
|
||||
}
|
||||
else
|
||||
{
|
||||
w64Bits |= m_carryBit; // Set the carry bit as the LSB
|
||||
m_carryBit = msb; // Store the msb as the next carry bit
|
||||
}
|
||||
|
||||
result = w64Bits;
|
||||
}
|
||||
break;
|
||||
|
||||
// Rotate right with lo bit wrapped over to hi bit
|
||||
case IDC_ROR:
|
||||
case IDC_RORC:
|
||||
if (m_fIntegerMode)
|
||||
{
|
||||
result = Integer(rat);
|
||||
@@ -70,7 +79,16 @@ CalcEngine::Rational CCalcEngine::SciCalcFunctions(CalcEngine::Rational const& r
|
||||
uint64_t w64Bits = result.ToUInt64_t();
|
||||
uint64_t lsb = ((w64Bits & 0x01) == 1) ? 1 : 0;
|
||||
w64Bits >>= 1; // RShift by 1
|
||||
w64Bits |= (lsb << (m_dwWordBitWidth - 1));
|
||||
|
||||
if (op == IDC_ROR)
|
||||
{
|
||||
w64Bits |= (lsb << (m_dwWordBitWidth - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
w64Bits |= (m_carryBit << (m_dwWordBitWidth - 1));
|
||||
m_carryBit = lsb;
|
||||
}
|
||||
|
||||
result = w64Bits;
|
||||
}
|
||||
@@ -133,6 +151,48 @@ CalcEngine::Rational CCalcEngine::SciCalcFunctions(CalcEngine::Rational const& r
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_SEC:
|
||||
if (!m_fIntegerMode)
|
||||
{
|
||||
result = m_bInv ? ACos(Invert(rat), m_angletype) : Invert(Cos(rat, m_angletype));
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_CSC:
|
||||
if (!m_fIntegerMode)
|
||||
{
|
||||
result = m_bInv ? ASin(Invert(rat), m_angletype) : Invert(Sin(rat, m_angletype));
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_COT:
|
||||
if (!m_fIntegerMode)
|
||||
{
|
||||
result = m_bInv ? ATan(Invert(rat), m_angletype) : Invert(Tan(rat, m_angletype));
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_SECH:
|
||||
if (!m_fIntegerMode)
|
||||
{
|
||||
result = m_bInv ? ACosh(Invert(rat)) : Invert(Cosh(rat));
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_CSCH:
|
||||
if (!m_fIntegerMode)
|
||||
{
|
||||
result = m_bInv ? ASinh(Invert(rat)) : Invert(Sinh(rat));
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_COTH:
|
||||
if (!m_fIntegerMode)
|
||||
{
|
||||
result = m_bInv ? ATanh(Invert(rat)) : Invert(Tanh(rat));
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_REC: /* Reciprocal. */
|
||||
result = Invert(rat);
|
||||
break;
|
||||
@@ -158,6 +218,10 @@ CalcEngine::Rational CCalcEngine::SciCalcFunctions(CalcEngine::Rational const& r
|
||||
result = Pow(10, rat);
|
||||
break;
|
||||
|
||||
case IDC_POW2:
|
||||
result = Pow(2, rat);
|
||||
break;
|
||||
|
||||
case IDC_LN: /* Functions for natural log. */
|
||||
result = m_bInv ? Exp(rat) : Log(rat);
|
||||
break;
|
||||
@@ -202,6 +266,18 @@ CalcEngine::Rational CCalcEngine::SciCalcFunctions(CalcEngine::Rational const& r
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDC_CEIL:
|
||||
result = (Frac(rat) > 0) ? Integer(rat + 1) : Integer(rat);
|
||||
break;
|
||||
|
||||
case IDC_FLOOR:
|
||||
result = (Frac(rat) < 0) ? Integer(rat - 1 ) : Integer(rat);
|
||||
break;
|
||||
|
||||
case IDC_ABS:
|
||||
result = Abs(rat);
|
||||
break;
|
||||
|
||||
} // end switch( op )
|
||||
}
|
||||
catch (uint32_t nErrCode)
|
||||
|
@@ -28,6 +28,14 @@ CalcEngine::Rational CCalcEngine::DoOperation(int operation, CalcEngine::Rationa
|
||||
result ^= rhs;
|
||||
break;
|
||||
|
||||
case IDC_NAND:
|
||||
result = (result & rhs) ^ m_chopNumbers[m_numwidth];
|
||||
break;
|
||||
|
||||
case IDC_NOR:
|
||||
result = (result | rhs) ^ m_chopNumbers[m_numwidth];
|
||||
break;
|
||||
|
||||
case IDC_RSHF:
|
||||
{
|
||||
if (m_fIntegerMode && result >= m_dwWordBitWidth) // Lsh/Rsh >= than current word size is always 0
|
||||
@@ -52,7 +60,16 @@ CalcEngine::Rational CCalcEngine::DoOperation(int operation, CalcEngine::Rationa
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDC_RSHFL:
|
||||
{
|
||||
if (m_fIntegerMode && result >= m_dwWordBitWidth) // Lsh/Rsh >= than current word size is always 0
|
||||
{
|
||||
throw CALC_E_NORESULT;
|
||||
}
|
||||
|
||||
result = rhs >> result;
|
||||
break;
|
||||
}
|
||||
case IDC_LSHF:
|
||||
if (m_fIntegerMode && result >= m_dwWordBitWidth) // Lsh/Rsh >= than current word size is always 0
|
||||
{
|
||||
@@ -140,6 +157,10 @@ CalcEngine::Rational CCalcEngine::DoOperation(int operation, CalcEngine::Rationa
|
||||
case IDC_ROOT: // Calculates rhs to the result(th) root.
|
||||
result = Root(rhs, result);
|
||||
break;
|
||||
|
||||
case IDC_LOGBASEX:
|
||||
result = (Log(result) / Log(rhs));
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (uint32_t dwErrCode)
|
||||
|
@@ -78,24 +78,32 @@
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
@@ -175,6 +183,7 @@
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@@ -209,6 +218,7 @@
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@@ -244,6 +254,7 @@
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@@ -278,6 +289,7 @@
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@@ -289,7 +301,6 @@
|
||||
<ClInclude Include="CalculatorHistory.h" />
|
||||
<ClInclude Include="CalculatorManager.h" />
|
||||
<ClInclude Include="CalculatorResource.h" />
|
||||
<ClInclude Include="CalculatorVector.h" />
|
||||
<ClInclude Include="Command.h" />
|
||||
<ClInclude Include="ExpressionCommand.h" />
|
||||
<ClInclude Include="ExpressionCommandInterface.h" />
|
||||
|
@@ -120,7 +120,6 @@
|
||||
<ClInclude Include="Ratpack\ratpak.h">
|
||||
<Filter>RatPack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CalculatorVector.h" />
|
||||
<ClInclude Include="Header Files\CalcEngine.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -7,25 +7,48 @@
|
||||
using namespace std;
|
||||
using namespace CalculationManager;
|
||||
|
||||
namespace
|
||||
{
|
||||
static wstring GetGeneratedExpression(const vector<pair<wstring, int>>& tokens)
|
||||
{
|
||||
wstring expression;
|
||||
bool isFirst = true;
|
||||
|
||||
for (auto const& token : tokens)
|
||||
{
|
||||
if (isFirst)
|
||||
{
|
||||
isFirst = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
expression += L' ';
|
||||
}
|
||||
expression.append(token.first);
|
||||
}
|
||||
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
|
||||
CalculatorHistory::CalculatorHistory(size_t maxSize)
|
||||
: m_maxHistorySize(maxSize)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int CalculatorHistory::AddToHistory(
|
||||
_In_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens,
|
||||
_In_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands,
|
||||
_In_ wstring_view result)
|
||||
_In_ shared_ptr<vector<pair<wstring, int>>> const& tokens,
|
||||
_In_ shared_ptr<vector<shared_ptr<IExpressionCommand>>> const& commands,
|
||||
wstring_view result)
|
||||
{
|
||||
unsigned int addedIndex;
|
||||
wstring generatedExpression;
|
||||
shared_ptr<HISTORYITEM> spHistoryItem = make_shared<HISTORYITEM>();
|
||||
|
||||
spHistoryItem->historyItemVector.spTokens = tokens;
|
||||
spHistoryItem->historyItemVector.spCommands = commands;
|
||||
|
||||
// to be changed when pszexp is back
|
||||
tokens->GetString(&generatedExpression);
|
||||
wstring generatedExpression = GetGeneratedExpression(*tokens);
|
||||
// Prefixing and suffixing the special Unicode markers to ensure that the expression
|
||||
// in the history doesn't get broken for RTL languages
|
||||
spHistoryItem->historyItemVector.expression = L'\u202d' + generatedExpression + L'\u202c';
|
||||
@@ -47,7 +70,7 @@ unsigned int CalculatorHistory::AddItem(_In_ shared_ptr<HISTORYITEM> const& spHi
|
||||
return lastIndex;
|
||||
}
|
||||
|
||||
bool CalculatorHistory::RemoveItem(_In_ unsigned int uIdx)
|
||||
bool CalculatorHistory::RemoveItem(unsigned int uIdx)
|
||||
{
|
||||
if (uIdx > m_historyItems.size() - 1)
|
||||
{
|
||||
@@ -63,17 +86,12 @@ vector<shared_ptr<HISTORYITEM>> const& CalculatorHistory::GetHistory()
|
||||
return m_historyItems;
|
||||
}
|
||||
|
||||
shared_ptr<HISTORYITEM> const& CalculatorHistory::GetHistoryItem(_In_ unsigned int uIdx)
|
||||
shared_ptr<HISTORYITEM> const& CalculatorHistory::GetHistoryItem(unsigned int uIdx)
|
||||
{
|
||||
assert(uIdx >= 0 && uIdx < m_historyItems.size());
|
||||
return m_historyItems.at(uIdx);
|
||||
}
|
||||
|
||||
CalculatorHistory::~CalculatorHistory(void)
|
||||
{
|
||||
ClearHistory();
|
||||
}
|
||||
|
||||
void CalculatorHistory::ClearHistory()
|
||||
{
|
||||
m_historyItems.clear();
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
@@ -15,8 +15,8 @@ namespace CalculationManager
|
||||
|
||||
struct HISTORYITEMVECTOR
|
||||
{
|
||||
std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> spTokens;
|
||||
std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> spCommands;
|
||||
std::shared_ptr<std::vector<std::pair<std::wstring, int>>> spTokens;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<IExpressionCommand>>> spCommands;
|
||||
std::wstring expression;
|
||||
std::wstring result;
|
||||
};
|
||||
@@ -31,8 +31,8 @@ namespace CalculationManager
|
||||
public:
|
||||
CalculatorHistory(const size_t maxSize);
|
||||
unsigned int AddToHistory(
|
||||
_In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& spTokens,
|
||||
_In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& spCommands,
|
||||
_In_ std::shared_ptr<std::vector<std::pair<std::wstring, int>>> const& spTokens,
|
||||
_In_ std::shared_ptr<std::vector<std::shared_ptr<IExpressionCommand>>> const& spCommands,
|
||||
std::wstring_view result);
|
||||
std::vector<std::shared_ptr<HISTORYITEM>> const& GetHistory();
|
||||
std::shared_ptr<HISTORYITEM> const& GetHistoryItem(unsigned int uIdx);
|
||||
@@ -43,7 +43,6 @@ namespace CalculationManager
|
||||
{
|
||||
return m_maxHistorySize;
|
||||
}
|
||||
~CalculatorHistory(void);
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<HISTORYITEM>> m_historyItems;
|
||||
|
@@ -75,14 +75,19 @@ namespace CalculationManager
|
||||
m_displayCallback->MemoryItemChanged(indexOfMemory);
|
||||
}
|
||||
|
||||
void CalculatorManager::InputChanged()
|
||||
{
|
||||
m_displayCallback->InputChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call the callback function using passed in IDisplayHelper.
|
||||
/// Used to set the expression display value on ViewModel
|
||||
/// </summary>
|
||||
/// <param name="expressionString">wstring representing expression to be displayed</param>
|
||||
void CalculatorManager::SetExpressionDisplay(
|
||||
_Inout_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens,
|
||||
_Inout_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands)
|
||||
_Inout_ shared_ptr<vector<pair<wstring, int>>> const& tokens,
|
||||
_Inout_ shared_ptr<vector<shared_ptr<IExpressionCommand>>> const& commands)
|
||||
{
|
||||
if (!m_inHistoryItemLoadMode)
|
||||
{
|
||||
@@ -240,6 +245,7 @@ namespace CalculationManager
|
||||
m_savedCommands.push_back(MapCommandForSerialize(command));
|
||||
}
|
||||
m_savedDegreeMode = m_currentDegreeMode;
|
||||
InputChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -283,6 +289,30 @@ namespace CalculationManager
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandINV));
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandTANH));
|
||||
break;
|
||||
case Command::CommandASEC:
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandINV));
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandSEC));
|
||||
break;
|
||||
case Command::CommandACSC:
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandINV));
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandCSC));
|
||||
break;
|
||||
case Command::CommandACOT:
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandINV));
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandCOT));
|
||||
break;
|
||||
case Command::CommandASECH:
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandINV));
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandSECH));
|
||||
break;
|
||||
case Command::CommandACSCH:
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandINV));
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandCSCH));
|
||||
break;
|
||||
case Command::CommandACOTH:
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandINV));
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(Command::CommandCOTH));
|
||||
break;
|
||||
case Command::CommandFE:
|
||||
m_isExponentialFormat = !m_isExponentialFormat;
|
||||
[[fallthrough]];
|
||||
@@ -290,6 +320,8 @@ namespace CalculationManager
|
||||
m_currentCalculatorEngine->ProcessCommand(static_cast<OpCode>(command));
|
||||
break;
|
||||
}
|
||||
|
||||
InputChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -330,6 +362,7 @@ namespace CalculationManager
|
||||
{
|
||||
m_currentCalculatorEngine->PersistedMemObject(m_persistedPrimaryValue);
|
||||
m_currentCalculatorEngine->ProcessCommand(IDC_RECALL);
|
||||
InputChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -376,6 +409,7 @@ namespace CalculationManager
|
||||
|
||||
this->MemorizedNumberSelect(indexOfMemory);
|
||||
m_currentCalculatorEngine->ProcessCommand(IDC_RECALL);
|
||||
InputChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -606,9 +640,9 @@ namespace CalculationManager
|
||||
if (pHistory)
|
||||
{
|
||||
pHistory->ClearHistory();
|
||||
for (unsigned int i = 0; i < history.size(); ++i)
|
||||
for (auto const& historyItem : history)
|
||||
{
|
||||
pHistory->AddItem(history[i]);
|
||||
pHistory->AddItem(historyItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -638,6 +672,11 @@ namespace CalculationManager
|
||||
return m_currentCalculatorEngine->FInRecordingState() ? true : false;
|
||||
}
|
||||
|
||||
bool CalculatorManager::IsInputEmpty()
|
||||
{
|
||||
return m_currentCalculatorEngine->IsInputEmpty();
|
||||
}
|
||||
|
||||
void CalculatorManager::SetInHistoryItemLoadMode(_In_ bool isHistoryItemLoadMode)
|
||||
{
|
||||
m_inHistoryItemLoadMode = isHistoryItemLoadMode;
|
||||
|
@@ -91,8 +91,8 @@ namespace CalculationManager
|
||||
void SetPrimaryDisplay(_In_ const std::wstring& displayString, _In_ bool isError) override;
|
||||
void SetIsInError(bool isError) override;
|
||||
void SetExpressionDisplay(
|
||||
_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
|
||||
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands) override;
|
||||
_Inout_ std::shared_ptr<std::vector<std::pair<std::wstring, int>>> const& tokens,
|
||||
_Inout_ std::shared_ptr<std::vector<std::shared_ptr<IExpressionCommand>>> const& commands) override;
|
||||
void SetMemorizedNumbers(_In_ const std::vector<std::wstring>& memorizedNumbers) override;
|
||||
void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) override;
|
||||
void SetParenthesisNumber(_In_ unsigned int parenthesisCount) override;
|
||||
@@ -101,8 +101,8 @@ namespace CalculationManager
|
||||
void MaxDigitsReached() override;
|
||||
void BinaryOperatorReceived() override;
|
||||
void MemoryItemChanged(unsigned int indexOfMemory) override;
|
||||
|
||||
CalculatorManager(ICalcDisplay* displayCallback, IResourceProvider* resourceProvider);
|
||||
void InputChanged() override;
|
||||
CalculatorManager(_In_ ICalcDisplay* displayCallback, _In_ IResourceProvider* resourceProvider);
|
||||
|
||||
void Reset(bool clearMemory = true);
|
||||
void SetStandardMode();
|
||||
@@ -118,7 +118,8 @@ namespace CalculationManager
|
||||
void MemorizedNumberClearAll();
|
||||
|
||||
bool IsEngineRecording();
|
||||
std::vector<unsigned char> GetSavedCommands()
|
||||
bool IsInputEmpty();
|
||||
const std::vector<unsigned char>& GetSavedCommands() const
|
||||
{
|
||||
return m_savedCommands;
|
||||
}
|
||||
|
@@ -1,8 +1,10 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace CalculationManager
|
||||
{
|
||||
class IResourceProvider
|
||||
@@ -19,6 +21,6 @@ namespace CalculationManager
|
||||
// ids "sDecimal", "sThousand" and "sGrouping". See
|
||||
// https://technet.microsoft.com/en-us/library/cc782655(v=ws.10).aspx
|
||||
// for what these values refer to.
|
||||
virtual std::wstring GetCEngineString(const std::wstring& id) = 0;
|
||||
virtual std::wstring GetCEngineString(std::wstring_view id) = 0;
|
||||
};
|
||||
}
|
||||
|
@@ -97,6 +97,7 @@ namespace CalculationManager
|
||||
CommandROL = 99,
|
||||
CommandROR = 100,
|
||||
CommandCOM = 101,
|
||||
|
||||
CommandSIN = 102,
|
||||
CommandCOS = 103,
|
||||
CommandTAN = 104,
|
||||
@@ -151,6 +152,34 @@ namespace CalculationManager
|
||||
CommandINV = 146,
|
||||
CommandSET_RESULT = 147,
|
||||
|
||||
CommandSEC = 400,
|
||||
CommandASEC = 401,
|
||||
CommandCSC = 402,
|
||||
CommandACSC = 403,
|
||||
CommandCOT = 404,
|
||||
CommandACOT = 405,
|
||||
|
||||
CommandSECH = 406,
|
||||
CommandASECH = 407,
|
||||
CommandCSCH = 408,
|
||||
CommandACSCH = 409,
|
||||
CommandCOTH = 410,
|
||||
CommandACOTH = 411,
|
||||
|
||||
CommandPOW2 = 412, // 2 ^ x
|
||||
CommandAbs = 413,
|
||||
CommandFloor = 414,
|
||||
CommandCeil = 415,
|
||||
CommandROLC = 416,
|
||||
CommandRORC = 417,
|
||||
CommandLogBaseX = 500,
|
||||
CommandNand = 501,
|
||||
CommandNor = 502,
|
||||
|
||||
CommandRSHFL = 505,
|
||||
CommandRand = 600,
|
||||
CommandEuler = 601,
|
||||
|
||||
CommandAnd = 86,
|
||||
CommandOR = 87,
|
||||
CommandNot = 101,
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <string>
|
||||
#include "Header Files/CCommand.h"
|
||||
#include "CalculatorVector.h"
|
||||
#include "ExpressionCommand.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -35,18 +34,18 @@ void CParentheses::Accept(_In_ ISerializeCommandVisitor& commandVisitor)
|
||||
|
||||
CUnaryCommand::CUnaryCommand(int command)
|
||||
{
|
||||
m_command = make_shared<CalculatorVector<int>>();
|
||||
m_command->Append(command);
|
||||
m_command = make_shared<vector<int>>();
|
||||
m_command->push_back(command);
|
||||
}
|
||||
|
||||
CUnaryCommand::CUnaryCommand(int command1, int command2)
|
||||
{
|
||||
m_command = make_shared<CalculatorVector<int>>();
|
||||
m_command->Append(command1);
|
||||
m_command->Append(command2);
|
||||
m_command = make_shared<vector<int>>();
|
||||
m_command->push_back(command1);
|
||||
m_command->push_back(command2);
|
||||
}
|
||||
|
||||
const shared_ptr<CalculatorVector<int>>& CUnaryCommand::GetCommands() const
|
||||
const shared_ptr<vector<int>>& CUnaryCommand::GetCommands() const
|
||||
{
|
||||
return m_command;
|
||||
}
|
||||
@@ -58,15 +57,15 @@ CalculationManager::CommandType CUnaryCommand::GetCommandType() const
|
||||
|
||||
void CUnaryCommand::SetCommand(int command)
|
||||
{
|
||||
m_command->Clear();
|
||||
m_command->Append(command);
|
||||
m_command->clear();
|
||||
m_command->push_back(command);
|
||||
}
|
||||
|
||||
void CUnaryCommand::SetCommands(int command1, int command2)
|
||||
{
|
||||
m_command->Clear();
|
||||
m_command->Append(command1);
|
||||
m_command->Append(command2);
|
||||
m_command->clear();
|
||||
m_command->push_back(command1);
|
||||
m_command->push_back(command2);
|
||||
}
|
||||
|
||||
void CUnaryCommand::Accept(_In_ ISerializeCommandVisitor& commandVisitor)
|
||||
@@ -99,7 +98,7 @@ void CBinaryCommand::Accept(_In_ ISerializeCommandVisitor& commandVisitor)
|
||||
commandVisitor.Visit(*this);
|
||||
}
|
||||
|
||||
COpndCommand::COpndCommand(shared_ptr<CalculatorVector<int>> const& commands, bool fNegative, bool fDecimal, bool fSciFmt)
|
||||
COpndCommand::COpndCommand(shared_ptr<vector<int>> const& commands, bool fNegative, bool fDecimal, bool fSciFmt)
|
||||
: m_commands(commands)
|
||||
, m_fNegative(fNegative)
|
||||
, m_fSciFmt(fSciFmt)
|
||||
@@ -115,27 +114,25 @@ void COpndCommand::Initialize(Rational const& rat)
|
||||
m_fInitialized = true;
|
||||
}
|
||||
|
||||
const shared_ptr<CalculatorVector<int>>& COpndCommand::GetCommands() const
|
||||
const shared_ptr<vector<int>>& COpndCommand::GetCommands() const
|
||||
{
|
||||
return m_commands;
|
||||
}
|
||||
|
||||
void COpndCommand::SetCommands(shared_ptr<CalculatorVector<int>> const& commands)
|
||||
void COpndCommand::SetCommands(shared_ptr<vector<int>> const& commands)
|
||||
{
|
||||
m_commands = commands;
|
||||
}
|
||||
|
||||
void COpndCommand::AppendCommand(int command)
|
||||
{
|
||||
unsigned int nCommands;
|
||||
m_commands->GetSize(&nCommands);
|
||||
if (m_fSciFmt)
|
||||
{
|
||||
ClearAllAndAppendCommand(static_cast<CalculationManager::Command>(command));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_commands->Append(command);
|
||||
m_commands->push_back(command);
|
||||
}
|
||||
|
||||
if (command == IDC_PNT)
|
||||
@@ -146,14 +143,8 @@ void COpndCommand::AppendCommand(int command)
|
||||
|
||||
void COpndCommand::ToggleSign()
|
||||
{
|
||||
unsigned int commandCount;
|
||||
m_commands->GetSize(&commandCount);
|
||||
|
||||
for (unsigned int i = 0; i < commandCount; i++)
|
||||
for (int nOpCode : *m_commands)
|
||||
{
|
||||
int nOpCode;
|
||||
m_commands->GetAt(i, &nOpCode);
|
||||
|
||||
if (nOpCode != IDC_0)
|
||||
{
|
||||
m_fNegative = !m_fNegative;
|
||||
@@ -170,8 +161,7 @@ void COpndCommand::RemoveFromEnd()
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int nCommands;
|
||||
m_commands->GetSize(&nCommands);
|
||||
const size_t nCommands = m_commands->size();
|
||||
|
||||
if (nCommands == 1)
|
||||
{
|
||||
@@ -179,13 +169,14 @@ void COpndCommand::RemoveFromEnd()
|
||||
}
|
||||
else
|
||||
{
|
||||
int nOpCode;
|
||||
m_commands->GetAt(nCommands - 1, &nOpCode);
|
||||
int nOpCode = m_commands->at(nCommands - 1);
|
||||
|
||||
if (nOpCode == IDC_PNT)
|
||||
{
|
||||
m_fDecimal = false;
|
||||
}
|
||||
m_commands->RemoveAt(nCommands - 1);
|
||||
|
||||
m_commands->pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,8 +203,8 @@ CalculationManager::CommandType COpndCommand::GetCommandType() const
|
||||
|
||||
void COpndCommand::ClearAllAndAppendCommand(CalculationManager::Command command)
|
||||
{
|
||||
m_commands->Clear();
|
||||
m_commands->Append(static_cast<int>(command));
|
||||
m_commands->clear();
|
||||
m_commands->push_back(static_cast<int>(command));
|
||||
m_fSciFmt = false;
|
||||
m_fNegative = false;
|
||||
m_fDecimal = false;
|
||||
@@ -223,31 +214,29 @@ const wstring& COpndCommand::GetToken(wchar_t decimalSymbol)
|
||||
{
|
||||
static const wchar_t chZero = L'0';
|
||||
|
||||
unsigned int nCommands;
|
||||
m_commands->GetSize(&nCommands);
|
||||
const size_t nCommands = m_commands->size();
|
||||
m_token.clear();
|
||||
int nOpCode;
|
||||
|
||||
for (unsigned int i = 0; i < nCommands; i++)
|
||||
for (size_t i = 0; i < nCommands; i++)
|
||||
{
|
||||
m_commands->GetAt(i, &nOpCode);
|
||||
int nOpCode = (*m_commands)[i];
|
||||
|
||||
if (nOpCode == IDC_PNT)
|
||||
{
|
||||
m_token.append(wstring{ decimalSymbol });
|
||||
m_token += decimalSymbol;
|
||||
}
|
||||
else if (nOpCode == IDC_EXP)
|
||||
{
|
||||
m_token.append(&chExp);
|
||||
int nextOpCode;
|
||||
m_commands->GetAt(i + 1, &nextOpCode);
|
||||
m_token += chExp;
|
||||
int nextOpCode = m_commands->at(i + 1);
|
||||
if (nextOpCode != IDC_SIGN)
|
||||
{
|
||||
m_token.append(&chPlus);
|
||||
m_token += chPlus;
|
||||
}
|
||||
}
|
||||
else if (nOpCode == IDC_SIGN)
|
||||
{
|
||||
m_token.append(&chNegate);
|
||||
m_token += chNegate;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -257,7 +246,7 @@ const wstring& COpndCommand::GetToken(wchar_t decimalSymbol)
|
||||
}
|
||||
|
||||
// Remove zeros
|
||||
for (unsigned int i = 0; i < m_token.size(); i++)
|
||||
for (size_t i = 0; i < m_token.size(); i++)
|
||||
{
|
||||
if (m_token.at(i) != chZero)
|
||||
{
|
||||
@@ -272,29 +261,26 @@ const wstring& COpndCommand::GetToken(wchar_t decimalSymbol)
|
||||
|
||||
if (m_fNegative)
|
||||
{
|
||||
m_token.insert(0, &chNegate);
|
||||
m_token.insert(0, 1, chNegate);
|
||||
}
|
||||
|
||||
return m_token;
|
||||
}
|
||||
}
|
||||
|
||||
m_token.clear();
|
||||
m_token.append(&chZero);
|
||||
m_token = chZero;
|
||||
|
||||
return m_token;
|
||||
}
|
||||
|
||||
wstring COpndCommand::GetString(uint32_t radix, int32_t precision)
|
||||
{
|
||||
wstring result{};
|
||||
|
||||
if (m_fInitialized)
|
||||
{
|
||||
result = m_value.ToString(radix, eNUMOBJ_FMT::FMT_FLOAT, precision);
|
||||
return m_value.ToString(radix, eNUMOBJ_FMT::FMT_FLOAT, precision);
|
||||
}
|
||||
|
||||
return result;
|
||||
return wstring{};
|
||||
}
|
||||
|
||||
void COpndCommand::Accept(_In_ ISerializeCommandVisitor& commandVisitor)
|
||||
|
@@ -23,14 +23,14 @@ class CUnaryCommand final : public IUnaryCommand
|
||||
public:
|
||||
CUnaryCommand(int command);
|
||||
CUnaryCommand(int command1, int command2);
|
||||
const std::shared_ptr<CalculatorVector<int>>& GetCommands() const override;
|
||||
const std::shared_ptr<std::vector<int>>& GetCommands() const override;
|
||||
CalculationManager::CommandType GetCommandType() const override;
|
||||
void SetCommand(int command) override;
|
||||
void SetCommands(int command1, int command2) override;
|
||||
void Accept(_In_ ISerializeCommandVisitor& commandVisitor) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<CalculatorVector<int>> m_command;
|
||||
std::shared_ptr<std::vector<int>> m_command;
|
||||
};
|
||||
|
||||
class CBinaryCommand final : public IBinaryCommand
|
||||
@@ -49,11 +49,11 @@ private:
|
||||
class COpndCommand final : public IOpndCommand
|
||||
{
|
||||
public:
|
||||
COpndCommand(std::shared_ptr<CalculatorVector<int>> const& commands, bool fNegative, bool fDecimal, bool fSciFmt);
|
||||
COpndCommand(std::shared_ptr<std::vector<int>> const& commands, bool fNegative, bool fDecimal, bool fSciFmt);
|
||||
void Initialize(CalcEngine::Rational const& rat);
|
||||
|
||||
const std::shared_ptr<CalculatorVector<int>>& GetCommands() const override;
|
||||
void SetCommands(std::shared_ptr<CalculatorVector<int>> const& commands) override;
|
||||
const std::shared_ptr<std::vector<int>>& GetCommands() const override;
|
||||
void SetCommands(std::shared_ptr<std::vector<int>> const& commands) override;
|
||||
void AppendCommand(int command) override;
|
||||
void ToggleSign() override;
|
||||
void RemoveFromEnd() override;
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
std::wstring GetString(uint32_t radix, int32_t precision);
|
||||
|
||||
private:
|
||||
std::shared_ptr<CalculatorVector<int>> m_commands;
|
||||
std::shared_ptr<std::vector<int>> m_commands;
|
||||
bool m_fNegative;
|
||||
bool m_fSciFmt;
|
||||
bool m_fDecimal;
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory> // for std::shared_ptr
|
||||
#include "CalculatorVector.h"
|
||||
#include <vector>
|
||||
#include "Command.h"
|
||||
|
||||
class ISerializeCommandVisitor;
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
class IUnaryCommand : public IOperatorCommand
|
||||
{
|
||||
public:
|
||||
virtual const std::shared_ptr<CalculatorVector<int>>& GetCommands() const = 0;
|
||||
virtual const std::shared_ptr<std::vector<int>>& GetCommands() const = 0;
|
||||
virtual void SetCommands(int command1, int command2) = 0;
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
class IOpndCommand : public IExpressionCommand
|
||||
{
|
||||
public:
|
||||
virtual const std::shared_ptr<CalculatorVector<int>>& GetCommands() const = 0;
|
||||
virtual const std::shared_ptr<std::vector<int>>& GetCommands() const = 0;
|
||||
virtual void AppendCommand(int command) = 0;
|
||||
virtual void ToggleSign() = 0;
|
||||
virtual void RemoveFromEnd() = 0;
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
virtual bool IsSciFmt() const = 0;
|
||||
virtual bool IsDecimalPresent() const = 0;
|
||||
virtual const std::wstring& GetToken(wchar_t decimalSymbol) = 0;
|
||||
virtual void SetCommands(std::shared_ptr<CalculatorVector<int>> const& commands) = 0;
|
||||
virtual void SetCommands(std::shared_ptr<std::vector<int>> const& commands) = 0;
|
||||
};
|
||||
|
||||
class IParenthesisCommand : public IExpressionCommand
|
||||
|
@@ -81,6 +81,7 @@
|
||||
#define IDC_ROL 99
|
||||
#define IDC_ROR 100
|
||||
#define IDC_COM 101
|
||||
|
||||
#define IDC_SIN 102
|
||||
#define IDC_COS 103
|
||||
#define IDC_TAN 104
|
||||
@@ -136,7 +137,44 @@
|
||||
#define IDC_INV 146
|
||||
#define IDC_SET_RESULT 147
|
||||
|
||||
#define IDC_LASTCONTROL IDC_SET_RESULT
|
||||
#define IDC_STRING_MAPPED_VALUES 400
|
||||
#define IDC_UNARYEXTENDEDFIRST IDC_STRING_MAPPED_VALUES
|
||||
#define IDC_SEC 400 // Secant
|
||||
// 401 reserved for inverse
|
||||
#define IDC_CSC 402 // Cosecant
|
||||
// 403 reserved for inverse
|
||||
#define IDC_COT 404 // Cotangent
|
||||
// 405 reserved for inverse
|
||||
|
||||
#define IDC_SECH 406 //Hyperbolic Secant
|
||||
// 407 reserved for inverse
|
||||
#define IDC_CSCH 408 //Hyperbolic Cosecant
|
||||
// 409 reserved for inverse
|
||||
#define IDC_COTH 410 //Hyperbolic Cotangent
|
||||
// 411 reserved for inverse
|
||||
|
||||
#define IDC_POW2 412 // 2 ^ x
|
||||
#define IDC_ABS 413 // Absolute Value
|
||||
#define IDC_FLOOR 414 // Floor
|
||||
#define IDC_CEIL 415 // Ceiling
|
||||
|
||||
#define IDC_ROLC 416 // Rotate Left Circular
|
||||
#define IDC_RORC 417 // Rotate Right Circular
|
||||
|
||||
#define IDC_UNARYEXTENDEDLAST IDC_RORC
|
||||
|
||||
#define IDC_LASTCONTROL IDC_CEIL
|
||||
|
||||
#define IDC_BINARYEXTENDEDFIRST 500
|
||||
#define IDC_LOGBASEX 500 // logx(y)
|
||||
#define IDC_NAND 501 // Nand
|
||||
#define IDC_NOR 502 // Nor
|
||||
|
||||
#define IDC_RSHFL 505 //Right Shift Logical
|
||||
#define IDC_BINARYEXTENDEDLAST IDC_RSHFL
|
||||
|
||||
#define IDC_RAND 600 // Random
|
||||
#define IDC_EULER 601 // e Constant
|
||||
|
||||
#define IDC_BINEDITSTART 700
|
||||
#define IDC_BINPOS0 700
|
||||
|
@@ -14,10 +14,10 @@
|
||||
*
|
||||
\****************************************************************************/
|
||||
|
||||
#include <random>
|
||||
#include "CCommand.h"
|
||||
#include "EngineStrings.h"
|
||||
#include "../Command.h"
|
||||
#include "../CalculatorVector.h"
|
||||
#include "../ExpressionCommand.h"
|
||||
#include "RadixType.h"
|
||||
#include "History.h" // for History Collector
|
||||
@@ -68,6 +68,10 @@ public:
|
||||
{
|
||||
return m_bError;
|
||||
}
|
||||
bool IsInputEmpty()
|
||||
{
|
||||
return m_input.IsEmpty() && (m_numberString.empty() || m_numberString == L"0");
|
||||
}
|
||||
bool FInRecordingState()
|
||||
{
|
||||
return m_bRecord;
|
||||
@@ -94,7 +98,7 @@ public:
|
||||
{
|
||||
return s_engineStrings[std::to_wstring(ids)];
|
||||
}
|
||||
static std::wstring_view GetString(std::wstring ids)
|
||||
static std::wstring_view GetString(std::wstring_view ids)
|
||||
{
|
||||
return s_engineStrings[ids];
|
||||
}
|
||||
@@ -103,6 +107,7 @@ public:
|
||||
return GetString(IdStrFromCmdId(nOpCode));
|
||||
}
|
||||
static std::wstring_view OpCodeToUnaryString(int nOpCode, bool fInv, ANGLE_TYPE angletype);
|
||||
static std::wstring_view OpCodeToBinaryString(int nOpCode, bool isIntegerMode);
|
||||
|
||||
private:
|
||||
bool m_fPrecedence;
|
||||
@@ -147,11 +152,16 @@ private:
|
||||
NUM_WIDTH m_numwidth; // one of qword, dword, word or byte mode.
|
||||
int32_t m_dwWordBitWidth; // # of bits in currently selected word size
|
||||
|
||||
std::unique_ptr<std::mt19937> m_randomGeneratorEngine;
|
||||
std::unique_ptr<std::uniform_real_distribution<>> m_distr;
|
||||
|
||||
uint64_t m_carryBit;
|
||||
|
||||
CHistoryCollector m_HistoryCollector; // Accumulator of each line of history as various commands are processed
|
||||
|
||||
std::array<CalcEngine::Rational, NUM_WIDTH_LENGTH> m_chopNumbers; // word size enforcement
|
||||
std::array<std::wstring, NUM_WIDTH_LENGTH> m_maxDecimalValueStrings; // maximum values represented by a given word width based off m_chopNumbers
|
||||
static std::unordered_map<std::wstring, std::wstring> s_engineStrings; // the string table shared across all instances
|
||||
static std::unordered_map<std::wstring_view, std::wstring> s_engineStrings; // the string table shared across all instances
|
||||
wchar_t m_decimalSeparator;
|
||||
wchar_t m_groupSeparator;
|
||||
|
||||
@@ -165,12 +175,14 @@ private:
|
||||
void DisplayAnnounceBinaryOperator();
|
||||
void SetPrimaryDisplay(const std::wstring& szText, bool isError = false);
|
||||
void ClearTemporaryValues();
|
||||
void ClearDisplay();
|
||||
CalcEngine::Rational TruncateNumForIntMath(CalcEngine::Rational const& rat);
|
||||
CalcEngine::Rational SciCalcFunctions(CalcEngine::Rational const& rat, uint32_t op);
|
||||
CalcEngine::Rational DoOperation(int operation, CalcEngine::Rational const& lhs, CalcEngine::Rational const& rhs);
|
||||
void SetRadixTypeAndNumWidth(RADIX_TYPE radixtype, NUM_WIDTH numwidth);
|
||||
int32_t DwWordBitWidthFromeNumWidth(NUM_WIDTH numwidth);
|
||||
uint32_t NRadixFromRadixType(RADIX_TYPE radixtype);
|
||||
double GenerateRandomNumber();
|
||||
|
||||
bool TryToggleBit(CalcEngine::Rational& rat, uint32_t wbitno);
|
||||
void CheckAndAddLastBinOpToHistory(bool addToHistory = true);
|
||||
|
@@ -66,6 +66,7 @@ namespace CalcEngine
|
||||
bool TryBeginExponent();
|
||||
void Backspace();
|
||||
void SetDecimalSymbol(wchar_t decSymbol);
|
||||
bool IsEmpty();
|
||||
std::wstring ToString(uint32_t radix);
|
||||
Rational ToRational(uint32_t radix, int32_t precision);
|
||||
|
||||
|
@@ -87,7 +87,6 @@ inline constexpr auto SIDS_XPOW3 = L"32";
|
||||
inline constexpr auto SIDS_NFACTORIAL = L"33";
|
||||
inline constexpr auto SIDS_RECIPROCAL = L"34";
|
||||
inline constexpr auto SIDS_DMS = L"35";
|
||||
inline constexpr auto SIDS_CUBEROOT = L"36";
|
||||
inline constexpr auto SIDS_POWTEN = L"37";
|
||||
inline constexpr auto SIDS_PERCENT = L"38";
|
||||
inline constexpr auto SIDS_SCIENTIFIC_NOTATION = L"39";
|
||||
@@ -172,125 +171,193 @@ inline constexpr auto SIDS_ERR_UNEX_END = L"117";
|
||||
inline constexpr auto SIDS_ERR_SG_INV_ERROR = L"118";
|
||||
inline constexpr auto SIDS_ERR_INPUT_OVERFLOW = L"119";
|
||||
inline constexpr auto SIDS_ERR_OUTPUT_OVERFLOW = L"120";
|
||||
inline constexpr auto SIDS_SECD = L"SecDeg";
|
||||
inline constexpr auto SIDS_SECR = L"SecRad";
|
||||
inline constexpr auto SIDS_SECG = L"SecGrad";
|
||||
inline constexpr auto SIDS_ASECD = L"InverseSecDeg";
|
||||
inline constexpr auto SIDS_ASECR = L"InverseSecRad";
|
||||
inline constexpr auto SIDS_ASECG = L"InverseSecGrad";
|
||||
inline constexpr auto SIDS_CSCD = L"CscDeg";
|
||||
inline constexpr auto SIDS_CSCR = L"CscRad";
|
||||
inline constexpr auto SIDS_CSCG = L"CscGrad";
|
||||
inline constexpr auto SIDS_ACSCD = L"InverseCscDeg";
|
||||
inline constexpr auto SIDS_ACSCR = L"InverseCscRad";
|
||||
inline constexpr auto SIDS_ACSCG = L"InverseCscGrad";
|
||||
inline constexpr auto SIDS_COTD = L"CotDeg";
|
||||
inline constexpr auto SIDS_COTR = L"CotRad";
|
||||
inline constexpr auto SIDS_COTG = L"CotGrad";
|
||||
inline constexpr auto SIDS_ACOTD = L"InverseCotDeg";
|
||||
inline constexpr auto SIDS_ACOTR = L"InverseCotRad";
|
||||
inline constexpr auto SIDS_ACOTG = L"InverseCotGrad";
|
||||
inline constexpr auto SIDS_SECH = L"Sech";
|
||||
inline constexpr auto SIDS_ASECH = L"InverseSech";
|
||||
inline constexpr auto SIDS_CSCH = L"Csch";
|
||||
inline constexpr auto SIDS_ACSCH = L"InverseCsch";
|
||||
inline constexpr auto SIDS_COTH = L"Coth";
|
||||
inline constexpr auto SIDS_ACOTH = L"InverseCoth";
|
||||
inline constexpr auto SIDS_TWOPOWX = L"TwoPowX";
|
||||
inline constexpr auto SIDS_LOGBASEX = L"LogBaseX";
|
||||
inline constexpr auto SIDS_ABS = L"Abs";
|
||||
inline constexpr auto SIDS_FLOOR = L"Floor";
|
||||
inline constexpr auto SIDS_CEIL = L"Ceil";
|
||||
inline constexpr auto SIDS_NAND = L"Nand";
|
||||
inline constexpr auto SIDS_NOR = L"Nor";
|
||||
inline constexpr auto SIDS_CUBEROOT = L"CubeRoot";
|
||||
inline constexpr auto SIDS_PROGRAMMER_MOD = L"ProgrammerMod";
|
||||
|
||||
// Include the resource key ID from above into this vector to load it into memory for the engine to use
|
||||
inline constexpr std::array<std::wstring_view, 120> g_sids = { SIDS_PLUS_MINUS,
|
||||
SIDS_C,
|
||||
SIDS_CE,
|
||||
SIDS_BACKSPACE,
|
||||
SIDS_DECIMAL_SEPARATOR,
|
||||
SIDS_EMPTY_STRING,
|
||||
SIDS_AND,
|
||||
SIDS_OR,
|
||||
SIDS_XOR,
|
||||
SIDS_LSH,
|
||||
SIDS_RSH,
|
||||
SIDS_DIVIDE,
|
||||
SIDS_MULTIPLY,
|
||||
SIDS_PLUS,
|
||||
SIDS_MINUS,
|
||||
SIDS_MOD,
|
||||
SIDS_YROOT,
|
||||
SIDS_POW_HAT,
|
||||
SIDS_INT,
|
||||
SIDS_ROL,
|
||||
SIDS_ROR,
|
||||
SIDS_NOT,
|
||||
SIDS_SIN,
|
||||
SIDS_COS,
|
||||
SIDS_TAN,
|
||||
SIDS_SINH,
|
||||
SIDS_COSH,
|
||||
SIDS_TANH,
|
||||
SIDS_LN,
|
||||
SIDS_LOG,
|
||||
SIDS_SQRT,
|
||||
SIDS_XPOW2,
|
||||
SIDS_XPOW3,
|
||||
SIDS_NFACTORIAL,
|
||||
SIDS_RECIPROCAL,
|
||||
SIDS_DMS,
|
||||
SIDS_CUBEROOT,
|
||||
SIDS_POWTEN,
|
||||
SIDS_PERCENT,
|
||||
SIDS_SCIENTIFIC_NOTATION,
|
||||
SIDS_PI,
|
||||
SIDS_EQUAL,
|
||||
SIDS_MC,
|
||||
SIDS_MR,
|
||||
SIDS_MS,
|
||||
SIDS_MPLUS,
|
||||
SIDS_MMINUS,
|
||||
SIDS_EXP,
|
||||
SIDS_OPEN_PAREN,
|
||||
SIDS_CLOSE_PAREN,
|
||||
SIDS_0,
|
||||
SIDS_1,
|
||||
SIDS_2,
|
||||
SIDS_3,
|
||||
SIDS_4,
|
||||
SIDS_5,
|
||||
SIDS_6,
|
||||
SIDS_7,
|
||||
SIDS_8,
|
||||
SIDS_9,
|
||||
SIDS_A,
|
||||
SIDS_B,
|
||||
SIDS_C,
|
||||
SIDS_D,
|
||||
SIDS_E,
|
||||
SIDS_F,
|
||||
SIDS_FRAC,
|
||||
SIDS_SIND,
|
||||
SIDS_COSD,
|
||||
SIDS_TAND,
|
||||
SIDS_ASIND,
|
||||
SIDS_ACOSD,
|
||||
SIDS_ATAND,
|
||||
SIDS_SINR,
|
||||
SIDS_COSR,
|
||||
SIDS_TANR,
|
||||
SIDS_ASINR,
|
||||
SIDS_ACOSR,
|
||||
SIDS_ATANR,
|
||||
SIDS_SING,
|
||||
SIDS_COSG,
|
||||
SIDS_TANG,
|
||||
SIDS_ASING,
|
||||
SIDS_ACOSG,
|
||||
SIDS_ATANG,
|
||||
SIDS_ASINH,
|
||||
SIDS_ACOSH,
|
||||
SIDS_ATANH,
|
||||
SIDS_POWE,
|
||||
SIDS_POWTEN2,
|
||||
SIDS_SQRT2,
|
||||
SIDS_SQR,
|
||||
SIDS_CUBE,
|
||||
SIDS_CUBERT,
|
||||
SIDS_FACT,
|
||||
SIDS_RECIPROC,
|
||||
SIDS_DEGREES,
|
||||
SIDS_NEGATE,
|
||||
SIDS_RSH,
|
||||
SIDS_DIVIDEBYZERO,
|
||||
SIDS_DOMAIN,
|
||||
SIDS_UNDEFINED,
|
||||
SIDS_POS_INFINITY,
|
||||
SIDS_NEG_INFINITY,
|
||||
SIDS_ABORTED,
|
||||
SIDS_NOMEM,
|
||||
SIDS_TOOMANY,
|
||||
SIDS_OVERFLOW,
|
||||
SIDS_NORESULT,
|
||||
SIDS_INSUFFICIENT_DATA,
|
||||
SIDS_ERR_UNK_CH,
|
||||
SIDS_ERR_UNK_FN,
|
||||
SIDS_ERR_UNEX_NUM,
|
||||
SIDS_ERR_UNEX_CH,
|
||||
SIDS_ERR_UNEX_SZ,
|
||||
SIDS_ERR_MISMATCH_CLOSE,
|
||||
SIDS_ERR_UNEX_END,
|
||||
SIDS_ERR_SG_INV_ERROR,
|
||||
SIDS_ERR_INPUT_OVERFLOW,
|
||||
SIDS_ERR_OUTPUT_OVERFLOW };
|
||||
inline constexpr std::array<std::wstring_view, 152> g_sids =
|
||||
{
|
||||
SIDS_PLUS_MINUS,
|
||||
SIDS_C,
|
||||
SIDS_CE,
|
||||
SIDS_BACKSPACE,
|
||||
SIDS_DECIMAL_SEPARATOR,
|
||||
SIDS_EMPTY_STRING,
|
||||
SIDS_AND,
|
||||
SIDS_OR,
|
||||
SIDS_XOR,
|
||||
SIDS_LSH,
|
||||
SIDS_RSH,
|
||||
SIDS_DIVIDE,
|
||||
SIDS_MULTIPLY,
|
||||
SIDS_PLUS,
|
||||
SIDS_MINUS,
|
||||
SIDS_MOD,
|
||||
SIDS_YROOT,
|
||||
SIDS_POW_HAT,
|
||||
SIDS_INT,
|
||||
SIDS_ROL,
|
||||
SIDS_ROR,
|
||||
SIDS_NOT,
|
||||
SIDS_SIN,
|
||||
SIDS_COS,
|
||||
SIDS_TAN,
|
||||
SIDS_SINH,
|
||||
SIDS_COSH,
|
||||
SIDS_TANH,
|
||||
SIDS_LN,
|
||||
SIDS_LOG,
|
||||
SIDS_SQRT,
|
||||
SIDS_XPOW2,
|
||||
SIDS_XPOW3,
|
||||
SIDS_NFACTORIAL,
|
||||
SIDS_RECIPROCAL,
|
||||
SIDS_DMS,
|
||||
SIDS_POWTEN,
|
||||
SIDS_PERCENT,
|
||||
SIDS_SCIENTIFIC_NOTATION,
|
||||
SIDS_PI,
|
||||
SIDS_EQUAL,
|
||||
SIDS_MC,
|
||||
SIDS_MR,
|
||||
SIDS_MS,
|
||||
SIDS_MPLUS,
|
||||
SIDS_MMINUS,
|
||||
SIDS_EXP,
|
||||
SIDS_OPEN_PAREN,
|
||||
SIDS_CLOSE_PAREN,
|
||||
SIDS_0,
|
||||
SIDS_1,
|
||||
SIDS_2,
|
||||
SIDS_3,
|
||||
SIDS_4,
|
||||
SIDS_5,
|
||||
SIDS_6,
|
||||
SIDS_7,
|
||||
SIDS_8,
|
||||
SIDS_9,
|
||||
SIDS_A,
|
||||
SIDS_B,
|
||||
SIDS_C,
|
||||
SIDS_D,
|
||||
SIDS_E,
|
||||
SIDS_F,
|
||||
SIDS_FRAC,
|
||||
SIDS_SIND,
|
||||
SIDS_COSD,
|
||||
SIDS_TAND,
|
||||
SIDS_ASIND,
|
||||
SIDS_ACOSD,
|
||||
SIDS_ATAND,
|
||||
SIDS_SINR,
|
||||
SIDS_COSR,
|
||||
SIDS_TANR,
|
||||
SIDS_ASINR,
|
||||
SIDS_ACOSR,
|
||||
SIDS_ATANR,
|
||||
SIDS_SING,
|
||||
SIDS_COSG,
|
||||
SIDS_TANG,
|
||||
SIDS_ASING,
|
||||
SIDS_ACOSG,
|
||||
SIDS_ATANG,
|
||||
SIDS_ASINH,
|
||||
SIDS_ACOSH,
|
||||
SIDS_ATANH,
|
||||
SIDS_POWE,
|
||||
SIDS_POWTEN2,
|
||||
SIDS_SQRT2,
|
||||
SIDS_SQR,
|
||||
SIDS_CUBE,
|
||||
SIDS_CUBERT,
|
||||
SIDS_FACT,
|
||||
SIDS_RECIPROC,
|
||||
SIDS_DEGREES,
|
||||
SIDS_NEGATE,
|
||||
SIDS_RSH,
|
||||
SIDS_DIVIDEBYZERO,
|
||||
SIDS_DOMAIN,
|
||||
SIDS_UNDEFINED,
|
||||
SIDS_POS_INFINITY,
|
||||
SIDS_NEG_INFINITY,
|
||||
SIDS_ABORTED,
|
||||
SIDS_NOMEM,
|
||||
SIDS_TOOMANY,
|
||||
SIDS_OVERFLOW,
|
||||
SIDS_NORESULT,
|
||||
SIDS_INSUFFICIENT_DATA,
|
||||
SIDS_ERR_UNK_CH,
|
||||
SIDS_ERR_UNK_FN,
|
||||
SIDS_ERR_UNEX_NUM,
|
||||
SIDS_ERR_UNEX_CH,
|
||||
SIDS_ERR_UNEX_SZ,
|
||||
SIDS_ERR_MISMATCH_CLOSE,
|
||||
SIDS_ERR_UNEX_END,
|
||||
SIDS_ERR_SG_INV_ERROR,
|
||||
SIDS_ERR_INPUT_OVERFLOW,
|
||||
SIDS_ERR_OUTPUT_OVERFLOW,
|
||||
SIDS_SECD,
|
||||
SIDS_SECG,
|
||||
SIDS_SECR,
|
||||
SIDS_ASECD,
|
||||
SIDS_ASECR,
|
||||
SIDS_ASECG,
|
||||
SIDS_CSCD,
|
||||
SIDS_CSCR,
|
||||
SIDS_CSCG,
|
||||
SIDS_ACSCD,
|
||||
SIDS_ACSCR,
|
||||
SIDS_ACSCG,
|
||||
SIDS_COTD,
|
||||
SIDS_COTR,
|
||||
SIDS_COTG,
|
||||
SIDS_ACOTD,
|
||||
SIDS_ACOTR,
|
||||
SIDS_ACOTG,
|
||||
SIDS_SECH,
|
||||
SIDS_ASECH,
|
||||
SIDS_CSCH,
|
||||
SIDS_ACSCH,
|
||||
SIDS_COTH,
|
||||
SIDS_ACOTH,
|
||||
SIDS_TWOPOWX,
|
||||
SIDS_LOGBASEX,
|
||||
SIDS_ABS,
|
||||
SIDS_FLOOR,
|
||||
SIDS_CEIL,
|
||||
SIDS_NAND,
|
||||
SIDS_NOR,
|
||||
SIDS_CUBEROOT,
|
||||
SIDS_PROGRAMMER_MOD,
|
||||
};
|
||||
|
@@ -21,8 +21,8 @@ public:
|
||||
~CHistoryCollector();
|
||||
void AddOpndToHistory(std::wstring_view numStr, CalcEngine::Rational const& rat, bool fRepetition = false);
|
||||
void RemoveLastOpndFromHistory();
|
||||
void AddBinOpToHistory(int nOpCode, bool fNoRepetition = true);
|
||||
void ChangeLastBinOp(int nOpCode, bool fPrecInvToHigher);
|
||||
void AddBinOpToHistory(int nOpCode, bool isIntgerMode, bool fNoRepetition = true);
|
||||
void ChangeLastBinOp(int nOpCode, bool fPrecInvToHigher, bool isIntgerMode);
|
||||
void AddUnaryOpToHistory(int nOpCode, bool fInv, ANGLE_TYPE angletype);
|
||||
void AddOpenBraceToHistory();
|
||||
void AddCloseBraceToHistory();
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
void EnclosePrecInversionBrackets();
|
||||
bool FOpndAddedToHistory();
|
||||
void CompleteHistoryLine(std::wstring_view numStr);
|
||||
void CompleteEquation(std::wstring_view numStr);
|
||||
void ClearHistoryLine(std::wstring_view errStr);
|
||||
int AddCommand(_In_ const std::shared_ptr<IExpressionCommand>& spCommand);
|
||||
void UpdateHistoryExpression(uint32_t radix, int32_t precision);
|
||||
@@ -50,8 +51,8 @@ private:
|
||||
int m_curOperandIndex; // Stack index for the above stack
|
||||
bool m_bLastOpndBrace; // iff the last opnd in history is already braced so we can avoid putting another one for unary operator
|
||||
wchar_t m_decimalSymbol;
|
||||
std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> m_spTokens;
|
||||
std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> m_spCommands;
|
||||
std::shared_ptr<std::vector<std::pair<std::wstring, int>>> m_spTokens;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<IExpressionCommand>>> m_spCommands;
|
||||
|
||||
private:
|
||||
void ReinitHistory();
|
||||
@@ -59,5 +60,5 @@ private:
|
||||
void TruncateEquationSzFromIch(int ich);
|
||||
void SetExpressionDisplay();
|
||||
void InsertSzInEquationSz(std::wstring_view str, int icommandIndex, int ich);
|
||||
std::shared_ptr<CalculatorVector<int>> GetOperandCommandsFromString(std::wstring_view numStr);
|
||||
std::shared_ptr<std::vector<int>> GetOperandCommandsFromString(std::wstring_view numStr);
|
||||
};
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../CalculatorVector.h"
|
||||
#include "../ExpressionCommandInterface.h"
|
||||
|
||||
// Callback interface to be implemented by the clients of CCalcEngine
|
||||
@@ -13,8 +12,8 @@ public:
|
||||
virtual void SetPrimaryDisplay(const std::wstring& pszText, bool isError) = 0;
|
||||
virtual void SetIsInError(bool isInError) = 0;
|
||||
virtual void SetExpressionDisplay(
|
||||
_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
|
||||
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands) = 0;
|
||||
_Inout_ std::shared_ptr<std::vector<std::pair<std::wstring, int>>> const& tokens,
|
||||
_Inout_ std::shared_ptr<std::vector<std::shared_ptr<IExpressionCommand>>> const& commands) = 0;
|
||||
virtual void SetParenthesisNumber(_In_ unsigned int count) = 0;
|
||||
virtual void OnNoRightParenAdded() = 0;
|
||||
virtual void MaxDigitsReached() = 0; // not an error but still need to inform UI layer.
|
||||
@@ -22,4 +21,5 @@ public:
|
||||
virtual void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) = 0;
|
||||
virtual void SetMemorizedNumbers(const std::vector<std::wstring>& memorizedNumbers) = 0;
|
||||
virtual void MemoryItemChanged(unsigned int indexOfMemory) = 0;
|
||||
virtual void InputChanged() = 0;
|
||||
};
|
||||
|
@@ -1,15 +1,17 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../ExpressionCommandInterface.h"
|
||||
|
||||
// Callback interface to be implemented by the clients of CCalcEngine if they require equation history
|
||||
class IHistoryDisplay
|
||||
{
|
||||
public:
|
||||
virtual ~IHistoryDisplay(){};
|
||||
virtual unsigned int AddToHistory(
|
||||
_In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
|
||||
_In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands,
|
||||
_In_ std::shared_ptr<std::vector<std::pair<std::wstring, int>>> const& tokens,
|
||||
_In_ std::shared_ptr<std::vector<std::shared_ptr<IExpressionCommand>>> const& commands,
|
||||
_In_ std::wstring_view result) = 0;
|
||||
};
|
||||
|
@@ -16,8 +16,7 @@ namespace CalcManager::NumberFormattingUtils
|
||||
return;
|
||||
}
|
||||
|
||||
wstring::iterator iter;
|
||||
for (iter = number.end() - 1;; iter--)
|
||||
for (auto iter = number.end() - 1;; iter--)
|
||||
{
|
||||
if (*iter != L'0')
|
||||
{
|
||||
@@ -25,9 +24,9 @@ namespace CalcManager::NumberFormattingUtils
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (*(number.end() - 1) == L'.')
|
||||
if (number.back() == L'.')
|
||||
{
|
||||
number.erase(number.end() - 1, number.end());
|
||||
number.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -41,45 +41,45 @@ typedef int32_t ResultCode;
|
||||
// CALC_E_DIVIDEBYZERO
|
||||
//
|
||||
// The current operation would require a divide by zero to complete
|
||||
#define CALC_E_DIVIDEBYZERO ((uint32_t)0x80000000)
|
||||
static constexpr uint32_t CALC_E_DIVIDEBYZERO = (uint32_t)0x80000000;
|
||||
|
||||
// CALC_E_DOMAIN
|
||||
//
|
||||
// The given input is not within the domain of this function
|
||||
#define CALC_E_DOMAIN ((uint32_t)0x80000001)
|
||||
static constexpr uint32_t CALC_E_DOMAIN = (uint32_t)0x80000001;
|
||||
|
||||
// CALC_E_INDEFINITE
|
||||
//
|
||||
// The result of this function is undefined
|
||||
#define CALC_E_INDEFINITE ((uint32_t)0x80000002)
|
||||
static constexpr uint32_t CALC_E_INDEFINITE = (uint32_t)0x80000002;
|
||||
|
||||
// CALC_E_POSINFINITY
|
||||
//
|
||||
// The result of this function is Positive Infinity.
|
||||
#define CALC_E_POSINFINITY ((uint32_t)0x80000003)
|
||||
static constexpr uint32_t CALC_E_POSINFINITY = (uint32_t)0x80000003;
|
||||
|
||||
// CALC_E_NEGINFINITY
|
||||
//
|
||||
// The result of this function is Negative Infinity
|
||||
#define CALC_E_NEGINFINITY ((uint32_t)0x80000004)
|
||||
static constexpr uint32_t CALC_E_NEGINFINITY = (uint32_t)0x80000004;
|
||||
|
||||
// CALC_E_INVALIDRANGE
|
||||
//
|
||||
// The given input is within the domain of the function but is beyond
|
||||
// the range for which calc can successfully compute the answer
|
||||
#define CALC_E_INVALIDRANGE ((uint32_t)0x80000006)
|
||||
static constexpr uint32_t CALC_E_INVALIDRANGE = (uint32_t)0x80000006;
|
||||
|
||||
// CALC_E_OUTOFMEMORY
|
||||
//
|
||||
// There is not enough free memory to complete the requested function
|
||||
#define CALC_E_OUTOFMEMORY ((uint32_t)0x80000007)
|
||||
static constexpr uint32_t CALC_E_OUTOFMEMORY = (uint32_t)0x80000007;
|
||||
|
||||
// CALC_E_OVERFLOW
|
||||
//
|
||||
// The result of this operation is an overflow
|
||||
#define CALC_E_OVERFLOW ((uint32_t)0x80000008)
|
||||
static constexpr uint32_t CALC_E_OVERFLOW = (uint32_t)0x80000008;
|
||||
|
||||
// CALC_E_NORESULT
|
||||
//
|
||||
// The result of this operation is undefined
|
||||
#define CALC_E_NORESULT ((uint32_t)0x80000009)
|
||||
static constexpr uint32_t CALC_E_NORESULT = (uint32_t)0x80000009;
|
||||
|
@@ -34,7 +34,7 @@ void _mulnumx(PNUMBER* pa, PNUMBER b);
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void mulnumx(PNUMBER* pa, PNUMBER b)
|
||||
void mulnumx(_Inout_ PNUMBER* pa, _In_ PNUMBER b)
|
||||
|
||||
{
|
||||
if (b->cdigit > 1 || b->mant[0] != 1 || b->exp != 0)
|
||||
@@ -172,7 +172,7 @@ void _mulnumx(PNUMBER* pa, PNUMBER b)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void numpowi32x(_Inout_ PNUMBER* proot, _In_ int32_t power)
|
||||
void numpowi32x(_Inout_ PNUMBER* proot, int32_t power)
|
||||
|
||||
{
|
||||
PNUMBER lret = i32tonum(1, BASEX);
|
||||
@@ -215,7 +215,7 @@ void _divnumx(PNUMBER* pa, PNUMBER b, int32_t precision);
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void divnumx(PNUMBER* pa, PNUMBER b, int32_t precision)
|
||||
void divnumx(_Inout_ PNUMBER* pa, _In_ PNUMBER b, int32_t precision)
|
||||
|
||||
{
|
||||
if (b->cdigit > 1 || b->mant[0] != 1 || b->exp != 0)
|
||||
|
@@ -145,7 +145,7 @@ void _dupnum(_In_ PNUMBER dest, _In_ const NUMBER* const src)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void _destroynum(_In_ PNUMBER pnum)
|
||||
void _destroynum(_Frees_ptr_opt_ PNUMBER pnum)
|
||||
|
||||
{
|
||||
if (pnum != nullptr)
|
||||
@@ -167,7 +167,7 @@ void _destroynum(_In_ PNUMBER pnum)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void _destroyrat(_In_ PRAT prat)
|
||||
void _destroyrat(_Frees_ptr_opt_ PRAT prat)
|
||||
|
||||
{
|
||||
if (prat != nullptr)
|
||||
@@ -760,7 +760,7 @@ PNUMBER StringToNumber(wstring_view numberString, uint32_t radix, int32_t precis
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
PRAT i32torat(_In_ int32_t ini32)
|
||||
PRAT i32torat(int32_t ini32)
|
||||
|
||||
{
|
||||
PRAT pratret = nullptr;
|
||||
@@ -784,7 +784,7 @@ PRAT i32torat(_In_ int32_t ini32)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
PRAT Ui32torat(_In_ uint32_t inui32)
|
||||
PRAT Ui32torat(uint32_t inui32)
|
||||
|
||||
{
|
||||
PRAT pratret = nullptr;
|
||||
|
@@ -39,7 +39,7 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void _exprat(PRAT* px, int32_t precision)
|
||||
void _exprat(_Inout_ PRAT* px, int32_t precision)
|
||||
|
||||
{
|
||||
CREATETAYLOR();
|
||||
@@ -58,7 +58,7 @@ void _exprat(PRAT* px, int32_t precision)
|
||||
DESTROYTAYLOR();
|
||||
}
|
||||
|
||||
void exprat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void exprat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT pwr = nullptr;
|
||||
@@ -150,7 +150,7 @@ void _lograt(PRAT* px, int32_t precision)
|
||||
DESTROYTAYLOR();
|
||||
}
|
||||
|
||||
void lograt(PRAT* px, int32_t precision)
|
||||
void lograt(_Inout_ PRAT* px, int32_t precision)
|
||||
|
||||
{
|
||||
bool fneglog;
|
||||
@@ -224,7 +224,7 @@ void lograt(PRAT* px, int32_t precision)
|
||||
destroyrat(pwr);
|
||||
}
|
||||
|
||||
void log10rat(PRAT* px, int32_t precision)
|
||||
void log10rat(_Inout_ PRAT* px, int32_t precision)
|
||||
|
||||
{
|
||||
lograt(px, precision);
|
||||
@@ -267,7 +267,7 @@ bool IsEven(PRAT x, uint32_t radix, int32_t precision)
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void powrat(PRAT* px, PRAT y, uint32_t radix, int32_t precision)
|
||||
void powrat(_Inout_ PRAT* px, _In_ PRAT y, uint32_t radix, int32_t precision)
|
||||
{
|
||||
// Handle cases where px or y is 0 by calling powratcomp directly
|
||||
if (zerrat(*px) || zerrat(y))
|
||||
@@ -294,7 +294,7 @@ void powrat(PRAT* px, PRAT y, uint32_t radix, int32_t precision)
|
||||
}
|
||||
}
|
||||
|
||||
void powratNumeratorDenominator(PRAT* px, PRAT y, uint32_t radix, int32_t precision)
|
||||
void powratNumeratorDenominator(_Inout_ PRAT* px, _In_ PRAT y, uint32_t radix, int32_t precision)
|
||||
{
|
||||
// Prepare rationals
|
||||
PRAT yNumerator = nullptr;
|
||||
@@ -403,7 +403,7 @@ void powratNumeratorDenominator(PRAT* px, PRAT y, uint32_t radix, int32_t precis
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void powratcomp(PRAT* px, PRAT y, uint32_t radix, int32_t precision)
|
||||
void powratcomp(_Inout_ PRAT* px, _In_ PRAT y, uint32_t radix, int32_t precision)
|
||||
{
|
||||
int32_t sign = SIGN(*px);
|
||||
|
||||
|
@@ -190,7 +190,7 @@ void _gamma(PRAT* pn, uint32_t radix, int32_t precision)
|
||||
destroyrat(sum);
|
||||
}
|
||||
|
||||
void factrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void factrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT fact = nullptr;
|
||||
|
@@ -83,7 +83,7 @@ void asinanglerat(_Inout_ PRAT* pa, ANGLE_TYPE angletype, uint32_t radix, int32_
|
||||
ascalerat(pa, angletype, precision);
|
||||
}
|
||||
|
||||
void asinrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void asinrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT pret = nullptr;
|
||||
@@ -190,7 +190,7 @@ void _acosrat(PRAT* px, int32_t precision)
|
||||
DESTROYTAYLOR();
|
||||
}
|
||||
|
||||
void acosrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void acosrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
int32_t sgn = SIGN(*px);
|
||||
@@ -276,7 +276,7 @@ void _atanrat(PRAT* px, int32_t precision)
|
||||
DESTROYTAYLOR();
|
||||
}
|
||||
|
||||
void atanrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void atanrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT tmpx = nullptr;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -47,7 +47,7 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void asinhrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void asinhrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT neg_pt_eight_five = nullptr;
|
||||
@@ -101,7 +101,7 @@ void asinhrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void acoshrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void acoshrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
if (rat_lt(*px, rat_one, precision))
|
||||
@@ -138,7 +138,7 @@ void acoshrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void atanhrat(PRAT* px, int32_t precision)
|
||||
void atanhrat(_Inout_ PRAT* px, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT ptmp = nullptr;
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
void lshrat(PRAT* pa, PRAT b, uint32_t radix, int32_t precision)
|
||||
void lshrat(_Inout_ PRAT* pa, _In_ PRAT b, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT pwr = nullptr;
|
||||
@@ -40,7 +40,7 @@ void lshrat(PRAT* pa, PRAT b, uint32_t radix, int32_t precision)
|
||||
}
|
||||
}
|
||||
|
||||
void rshrat(PRAT* pa, PRAT b, uint32_t radix, int32_t precision)
|
||||
void rshrat(_Inout_ PRAT* pa, _In_ PRAT b, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT pwr = nullptr;
|
||||
@@ -73,19 +73,19 @@ enum
|
||||
FUNC_XOR
|
||||
} BOOL_FUNCS;
|
||||
|
||||
void andrat(PRAT* pa, PRAT b, uint32_t radix, int32_t precision)
|
||||
void andrat(_Inout_ PRAT* pa, _In_ PRAT b, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
boolrat(pa, b, FUNC_AND, radix, precision);
|
||||
}
|
||||
|
||||
void orrat(PRAT* pa, PRAT b, uint32_t radix, int32_t precision)
|
||||
void orrat(_Inout_ PRAT* pa, _In_ PRAT b, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
boolrat(pa, b, FUNC_OR, radix, precision);
|
||||
}
|
||||
|
||||
void xorrat(PRAT* pa, PRAT b, uint32_t radix, int32_t precision)
|
||||
void xorrat(_Inout_ PRAT* pa, _In_ PRAT b, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
boolrat(pa, b, FUNC_XOR, radix, precision);
|
||||
@@ -191,7 +191,7 @@ void boolnum(PNUMBER* pa, PNUMBER b, int func)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void remrat(PRAT* pa, PRAT b)
|
||||
void remrat(_Inout_ PRAT* pa, _In_ PRAT b)
|
||||
|
||||
{
|
||||
if (zerrat(b))
|
||||
@@ -228,7 +228,7 @@ void remrat(PRAT* pa, PRAT b)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void modrat(PRAT* pa, PRAT b)
|
||||
void modrat(_Inout_ PRAT* pa, _In_ PRAT b)
|
||||
{
|
||||
// contrary to remrat(X, 0) returning 0, modrat(X, 0) must return X
|
||||
if (zerrat(b))
|
||||
|
@@ -43,7 +43,7 @@ using namespace std;
|
||||
|
||||
void _addnum(PNUMBER* pa, PNUMBER b, uint32_t radix);
|
||||
|
||||
void addnum(PNUMBER* pa, PNUMBER b, uint32_t radix)
|
||||
void addnum(_Inout_ PNUMBER* pa, _In_ PNUMBER b, uint32_t radix)
|
||||
|
||||
{
|
||||
if (b->cdigit > 1 || b->mant[0] != 0)
|
||||
@@ -186,7 +186,7 @@ void _addnum(PNUMBER* pa, PNUMBER b, uint32_t radix)
|
||||
|
||||
void _mulnum(PNUMBER* pa, PNUMBER b, uint32_t radix);
|
||||
|
||||
void mulnum(PNUMBER* pa, PNUMBER b, uint32_t radix)
|
||||
void mulnum(_Inout_ PNUMBER* pa, _In_ PNUMBER b, uint32_t radix)
|
||||
|
||||
{
|
||||
if (b->cdigit > 1 || b->mant[0] != 1 || b->exp != 0)
|
||||
@@ -302,7 +302,7 @@ void _mulnum(PNUMBER* pa, PNUMBER b, uint32_t radix)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void remnum(PNUMBER* pa, PNUMBER b, uint32_t radix)
|
||||
void remnum(_Inout_ PNUMBER* pa, _In_ PNUMBER b, uint32_t radix)
|
||||
|
||||
{
|
||||
PNUMBER tmp = nullptr; // tmp is the working remainder.
|
||||
@@ -365,7 +365,7 @@ void remnum(PNUMBER* pa, PNUMBER b, uint32_t radix)
|
||||
|
||||
void _divnum(PNUMBER* pa, PNUMBER b, uint32_t radix, int32_t precision);
|
||||
|
||||
void divnum(PNUMBER* pa, PNUMBER b, uint32_t radix, int32_t precision)
|
||||
void divnum(_Inout_ PNUMBER* pa, _In_ PNUMBER b, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
if (b->cdigit > 1 || b->mant[0] != 1 || b->exp != 0)
|
||||
@@ -489,7 +489,7 @@ void _divnum(PNUMBER* pa, PNUMBER b, uint32_t radix, int32_t precision)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool equnum(PNUMBER a, PNUMBER b)
|
||||
bool equnum(_In_ PNUMBER a, _In_ PNUMBER b)
|
||||
|
||||
{
|
||||
int32_t diff;
|
||||
@@ -555,7 +555,7 @@ bool equnum(PNUMBER a, PNUMBER b)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool lessnum(PNUMBER a, PNUMBER b)
|
||||
bool lessnum(_In_ PNUMBER a, _In_ PNUMBER b)
|
||||
|
||||
{
|
||||
int32_t diff;
|
||||
@@ -614,7 +614,7 @@ bool lessnum(PNUMBER a, PNUMBER b)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
bool zernum(PNUMBER a)
|
||||
bool zernum(_In_ PNUMBER a)
|
||||
|
||||
{
|
||||
int32_t length;
|
||||
|
@@ -37,7 +37,7 @@ using namespace std;
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void gcdrat(PRAT* pa, int32_t precision)
|
||||
void gcdrat(_Inout_ PRAT* pa, int32_t precision)
|
||||
|
||||
{
|
||||
PNUMBER pgcd = nullptr;
|
||||
@@ -70,7 +70,7 @@ void gcdrat(PRAT* pa, int32_t precision)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void fracrat(PRAT* pa, uint32_t radix, int32_t precision)
|
||||
void fracrat(_Inout_ PRAT* pa, uint32_t radix, int32_t precision)
|
||||
{
|
||||
// Only do the flatrat operation if number is nonzero.
|
||||
// and only if the bottom part is not one.
|
||||
@@ -98,7 +98,7 @@ void fracrat(PRAT* pa, uint32_t radix, int32_t precision)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void mulrat(PRAT* pa, PRAT b, int32_t precision)
|
||||
void mulrat(_Inout_ PRAT* pa, _In_ PRAT b, int32_t precision)
|
||||
|
||||
{
|
||||
// Only do the multiply if it isn't zero.
|
||||
@@ -132,7 +132,7 @@ void mulrat(PRAT* pa, PRAT b, int32_t precision)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void divrat(PRAT* pa, PRAT b, int32_t precision)
|
||||
void divrat(_Inout_ PRAT* pa, _In_ PRAT b, int32_t precision)
|
||||
|
||||
{
|
||||
if (!zernum((*pa)->pp))
|
||||
@@ -182,7 +182,7 @@ void divrat(PRAT* pa, PRAT b, int32_t precision)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void subrat(PRAT* pa, PRAT b, int32_t precision)
|
||||
void subrat(_Inout_ PRAT* pa, _In_ PRAT b, int32_t precision)
|
||||
|
||||
{
|
||||
b->pp->sign *= -1;
|
||||
@@ -203,7 +203,7 @@ void subrat(PRAT* pa, PRAT b, int32_t precision)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void addrat(PRAT* pa, PRAT b, int32_t precision)
|
||||
void addrat(_Inout_ PRAT* pa, _In_ PRAT b, int32_t precision)
|
||||
|
||||
{
|
||||
PNUMBER bot = nullptr;
|
||||
@@ -255,7 +255,7 @@ void addrat(PRAT* pa, PRAT b, int32_t precision)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void rootrat(PRAT* py, PRAT n, uint32_t radix, int32_t precision)
|
||||
void rootrat(_Inout_ PRAT* py, _In_ PRAT n, uint32_t radix, int32_t precision)
|
||||
{
|
||||
// Initialize 1/n
|
||||
PRAT oneovern = nullptr;
|
||||
@@ -280,7 +280,7 @@ void rootrat(PRAT* py, PRAT n, uint32_t radix, int32_t precision)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool zerrat(PRAT a)
|
||||
bool zerrat(_In_ PRAT a)
|
||||
|
||||
{
|
||||
return (zernum(a->pp));
|
||||
|
@@ -369,7 +369,7 @@ extern PNUMBER i32factnum(int32_t ini32, uint32_t radix);
|
||||
extern PNUMBER i32prodnum(int32_t start, int32_t stop, uint32_t radix);
|
||||
extern PNUMBER i32tonum(int32_t ini32, uint32_t radix);
|
||||
extern PNUMBER Ui32tonum(uint32_t ini32, uint32_t radix);
|
||||
extern PNUMBER numtonRadixx(PNUMBER a, uint32_t radix);
|
||||
extern PNUMBER numtonRadixx(_In_ PNUMBER a, uint32_t radix);
|
||||
|
||||
// creates a empty/undefined rational representation (p/q)
|
||||
extern PRAT _createrat(void);
|
||||
@@ -446,8 +446,8 @@ extern void tananglerat(_Inout_ PRAT* px, ANGLE_TYPE angletype, uint32_t radix,
|
||||
|
||||
extern void _dupnum(_In_ PNUMBER dest, _In_ const NUMBER* const src);
|
||||
|
||||
extern void _destroynum(_In_ PNUMBER pnum);
|
||||
extern void _destroyrat(_In_ PRAT prat);
|
||||
extern void _destroynum(_Frees_ptr_opt_ PNUMBER pnum);
|
||||
extern void _destroyrat(_Frees_ptr_opt_ PRAT prat);
|
||||
extern void addnum(_Inout_ PNUMBER* pa, _In_ PNUMBER b, uint32_t radix);
|
||||
extern void addrat(_Inout_ PRAT* pa, _In_ PRAT b, int32_t precision);
|
||||
extern void andrat(_Inout_ PRAT* pa, _In_ PRAT b, uint32_t radix, int32_t precision);
|
||||
|
@@ -296,7 +296,7 @@ void ChangeConstants(uint32_t radix, int32_t precision)
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void intrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void intrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
{
|
||||
// Only do the intrat operation if number is nonzero.
|
||||
// and only if the bottom part is not one.
|
||||
@@ -328,7 +328,7 @@ void intrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool rat_equ(PRAT a, PRAT b, int32_t precision)
|
||||
bool rat_equ(_In_ PRAT a, _In_ PRAT b, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT rattmp = nullptr;
|
||||
@@ -351,7 +351,7 @@ bool rat_equ(PRAT a, PRAT b, int32_t precision)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool rat_ge(PRAT a, PRAT b, int32_t precision)
|
||||
bool rat_ge(_In_ PRAT a, _In_ PRAT b, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT rattmp = nullptr;
|
||||
@@ -375,7 +375,7 @@ bool rat_ge(PRAT a, PRAT b, int32_t precision)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool rat_gt(PRAT a, PRAT b, int32_t precision)
|
||||
bool rat_gt(_In_ PRAT a, _In_ PRAT b, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT rattmp = nullptr;
|
||||
@@ -399,7 +399,7 @@ bool rat_gt(PRAT a, PRAT b, int32_t precision)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool rat_le(PRAT a, PRAT b, int32_t precision)
|
||||
bool rat_le(_In_ PRAT a, _In_ PRAT b, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT rattmp = nullptr;
|
||||
@@ -423,7 +423,7 @@ bool rat_le(PRAT a, PRAT b, int32_t precision)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool rat_lt(PRAT a, PRAT b, int32_t precision)
|
||||
bool rat_lt(_In_ PRAT a, _In_ PRAT b, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT rattmp = nullptr;
|
||||
@@ -447,7 +447,7 @@ bool rat_lt(PRAT a, PRAT b, int32_t precision)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool rat_neq(PRAT a, PRAT b, int32_t precision)
|
||||
bool rat_neq(_In_ PRAT a, _In_ PRAT b, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT rattmp = nullptr;
|
||||
@@ -470,7 +470,7 @@ bool rat_neq(PRAT a, PRAT b, int32_t precision)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void scale(PRAT* px, PRAT scalefact, uint32_t radix, int32_t precision)
|
||||
void scale(_Inout_ PRAT* px, _In_ PRAT scalefact, uint32_t radix, int32_t precision)
|
||||
{
|
||||
PRAT pret = nullptr;
|
||||
DUPRAT(pret, *px);
|
||||
@@ -503,7 +503,7 @@ void scale(PRAT* px, PRAT scalefact, uint32_t radix, int32_t precision)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void scale2pi(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void scale2pi(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
{
|
||||
PRAT pret = nullptr;
|
||||
PRAT my_two_pi = nullptr;
|
||||
@@ -546,7 +546,7 @@ void scale2pi(PRAT* px, uint32_t radix, int32_t precision)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void inbetween(PRAT* px, PRAT range, int32_t precision)
|
||||
void inbetween(_In_ PRAT* px, _In_ PRAT range, int32_t precision)
|
||||
|
||||
{
|
||||
if (rat_gt(*px, range, precision))
|
||||
@@ -575,7 +575,7 @@ void inbetween(PRAT* px, PRAT range, int32_t precision)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void _dumprawrat(const wchar_t* varname, PRAT rat, wostream& out)
|
||||
void _dumprawrat(_In_ const wchar_t* varname, _In_ PRAT rat, wostream& out)
|
||||
|
||||
{
|
||||
_dumprawnum(varname, rat->pp, out);
|
||||
@@ -593,7 +593,7 @@ void _dumprawrat(const wchar_t* varname, PRAT rat, wostream& out)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void _dumprawnum(const wchar_t* varname, PNUMBER num, wostream& out)
|
||||
void _dumprawnum(_In_ const wchar_t* varname, _In_ PNUMBER num, wostream& out)
|
||||
|
||||
{
|
||||
int i;
|
||||
@@ -676,7 +676,7 @@ void _readconstants(void)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void trimit(PRAT* px, int32_t precision)
|
||||
void trimit(_Inout_ PRAT* px, int32_t precision)
|
||||
|
||||
{
|
||||
if (!g_ftrueinfinite)
|
||||
|
@@ -187,7 +187,7 @@ void _cosrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
}
|
||||
}
|
||||
|
||||
void cosrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void cosrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
{
|
||||
scale2pi(px, radix, precision);
|
||||
_cosrat(px, radix, precision);
|
||||
@@ -257,7 +257,7 @@ void _tanrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
destroyrat(ptmp);
|
||||
}
|
||||
|
||||
void tanrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void tanrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
{
|
||||
scale2pi(px, radix, precision);
|
||||
_tanrat(px, radix, precision);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -88,7 +88,7 @@ void _sinhrat(PRAT* px, int32_t precision)
|
||||
DESTROYTAYLOR();
|
||||
}
|
||||
|
||||
void sinhrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void sinhrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT tmpx = nullptr;
|
||||
@@ -169,7 +169,7 @@ void _coshrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
DESTROYTAYLOR();
|
||||
}
|
||||
|
||||
void coshrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void coshrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT tmpx = nullptr;
|
||||
@@ -211,7 +211,7 @@ void coshrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void tanhrat(PRAT* px, uint32_t radix, int32_t precision)
|
||||
void tanhrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
|
||||
|
||||
{
|
||||
PRAT ptmp = nullptr;
|
||||
|
@@ -401,43 +401,43 @@ void UnitConverter::SendCommand(Command command)
|
||||
switch (command)
|
||||
{
|
||||
case Command::Zero:
|
||||
m_currentDisplay += L"0";
|
||||
m_currentDisplay += L'0';
|
||||
break;
|
||||
|
||||
case Command::One:
|
||||
m_currentDisplay += L"1";
|
||||
m_currentDisplay += L'1';
|
||||
break;
|
||||
|
||||
case Command::Two:
|
||||
m_currentDisplay += L"2";
|
||||
m_currentDisplay += L'2';
|
||||
break;
|
||||
|
||||
case Command::Three:
|
||||
m_currentDisplay += L"3";
|
||||
m_currentDisplay += L'3';
|
||||
break;
|
||||
|
||||
case Command::Four:
|
||||
m_currentDisplay += L"4";
|
||||
m_currentDisplay += L'4';
|
||||
break;
|
||||
|
||||
case Command::Five:
|
||||
m_currentDisplay += L"5";
|
||||
m_currentDisplay += L'5';
|
||||
break;
|
||||
|
||||
case Command::Six:
|
||||
m_currentDisplay += L"6";
|
||||
m_currentDisplay += L'6';
|
||||
break;
|
||||
|
||||
case Command::Seven:
|
||||
m_currentDisplay += L"7";
|
||||
m_currentDisplay += L'7';
|
||||
break;
|
||||
|
||||
case Command::Eight:
|
||||
m_currentDisplay += L"8";
|
||||
m_currentDisplay += L'8';
|
||||
break;
|
||||
|
||||
case Command::Nine:
|
||||
m_currentDisplay += L"9";
|
||||
m_currentDisplay += L'9';
|
||||
break;
|
||||
|
||||
case Command::Decimal:
|
||||
@@ -445,7 +445,7 @@ void UnitConverter::SendCommand(Command command)
|
||||
clearBack = false;
|
||||
if (!m_currentHasDecimal)
|
||||
{
|
||||
m_currentDisplay += L".";
|
||||
m_currentDisplay += L'.';
|
||||
m_currentHasDecimal = true;
|
||||
}
|
||||
break;
|
||||
|
@@ -22,3 +22,5 @@
|
||||
#include <winerror.h>
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <random>
|
||||
#include <iomanip>
|
||||
|
Reference in New Issue
Block a user