Apply spell check (#41)
This commit is contained in:
@@ -59,7 +59,7 @@ bool CalcInput::TryToggleSign(bool isIntegerMode, wstring_view maxNumStr)
|
||||
bool CalcInput::TryAddDigit(unsigned int value, uint32_t radix, bool isIntegerMode, wstring_view maxNumStr, long wordBitWidth, int maxDigits)
|
||||
{
|
||||
// Convert from an integer into a character
|
||||
// This includes both normal digits and alpha 'digits' for radices > 10
|
||||
// This includes both normal digits and alpha 'digits' for radixes > 10
|
||||
auto chDigit = static_cast<wchar_t>((value < 10) ? (L'0' + value) : (L'A' + value - 10));
|
||||
|
||||
CalcNumSec* pNumSec;
|
||||
@@ -80,7 +80,7 @@ bool CalcInput::TryAddDigit(unsigned int value, uint32_t radix, bool isIntegerMo
|
||||
maxCount++;
|
||||
}
|
||||
// First leading 0 is not counted in input restriction as the output can be of that form
|
||||
// See NumberToString algorithm. REVIEW: We dont have such input restriction mimicking based on output of NumberToString for exponent
|
||||
// See NumberToString algorithm. REVIEW: We don't have such input restriction mimicking based on output of NumberToString for exponent
|
||||
// NumberToString can give 10 digit exponent, but we still restrict the exponent here to be only 4 digits.
|
||||
if (!pNumSec->IsEmpty() && pNumSec->value.front() == L'0')
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
@@ -14,8 +14,8 @@ bool IsBinOpCode(WPARAM opCode)
|
||||
return IsOpInRange(opCode, IDC_AND, IDC_PWR);
|
||||
}
|
||||
|
||||
// WARNING: IDC_SIGN is a special unary op but still this doesnt catch this. Caller has to be aware
|
||||
// of it and catch it themself or not needing this
|
||||
// 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(WPARAM opCode)
|
||||
{
|
||||
return IsOpInRange(opCode, IDC_UNARYFIRST, IDC_UNARYLAST);
|
||||
|
||||
@@ -129,7 +129,7 @@ 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 happenned. i.e. previous op was lower or equal to its previous op, but the new
|
||||
// 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)
|
||||
{
|
||||
@@ -196,7 +196,7 @@ bool CHistoryCollector::FOpndAddedToHistory()
|
||||
|
||||
// AddUnaryOpToHistory
|
||||
//
|
||||
// This is does the postfix to prefix transalation of the input and adds the text to the history. Eg. doing 2 + 4 (sqrt),
|
||||
// This is does the postfix to prefix translation of the input and adds the text to the history. Eg. doing 2 + 4 (sqrt),
|
||||
// this routine will ensure the last sqrt call unary operator, actually goes back in history and wraps 4 in sqrt(4)
|
||||
//
|
||||
void CHistoryCollector::AddUnaryOpToHistory(int nOpCode, bool fInv, ANGLE_TYPE angletype)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/****************************Module*Header***********************************\
|
||||
* Module Name: SCICOMM.C
|
||||
*
|
||||
* Module Descripton:
|
||||
* Module Description:
|
||||
*
|
||||
* Warnings:
|
||||
*
|
||||
@@ -28,8 +28,8 @@ using namespace CalcEngine;
|
||||
|
||||
// NPrecedenceOfOp
|
||||
//
|
||||
// returns a virtual number for precendence for the operator. We expect binary operator only, otherwise the lowest number
|
||||
// 0 is returned. Higher the number, higher the precendence of the operator.
|
||||
// returns a virtual number for precedence for the operator. We expect binary operator only, otherwise the lowest number
|
||||
// 0 is returned. Higher the number, higher the precedence of the operator.
|
||||
INT NPrecedenceOfOp(int nopCode)
|
||||
{
|
||||
static BYTE rgbPrec[] = { 0,0, IDC_OR,0, IDC_XOR,0, IDC_AND,1,
|
||||
@@ -53,12 +53,12 @@ INT NPrecedenceOfOp(int nopCode)
|
||||
// HandleErrorCommand
|
||||
//
|
||||
// When it is discovered by the state machine that at this point the input is not valid (eg. "1+)"), we want to proceed as though this input never
|
||||
// occured and may be some feedback to user like Beep. The rest of input can then continue by just ignoring this command.
|
||||
// occurred and may be some feedback to user like Beep. The rest of input can then continue by just ignoring this command.
|
||||
void CCalcEngine::HandleErrorCommand(WPARAM idc)
|
||||
{
|
||||
if (!IsGuiSettingOpCode(idc))
|
||||
{
|
||||
// we would have saved the prev command. Need to unremember this state
|
||||
// we would have saved the prev command. Need to forget this state
|
||||
m_nTempCom = m_nLastCom;
|
||||
}
|
||||
}
|
||||
@@ -184,23 +184,23 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
|
||||
if (IsBinOpCode(m_nLastCom))
|
||||
{
|
||||
INT nPrev;
|
||||
bool fPrecInvToHigher = false; // Is Precedence Invertion from lower to higher precedence happenning ??
|
||||
bool fPrecInvToHigher = false; // Is Precedence Inversion from lower to higher precedence happening ??
|
||||
|
||||
m_nOpCode = (INT)wParam;
|
||||
|
||||
// Check to see if by changing this binop, a Precedence invertion is happenning.
|
||||
// Check to see if by changing this binop, a Precedence inversion is happening.
|
||||
// Eg. 1 * 2 + and + is getting changed to ^. The previous precedence rules would have already computed
|
||||
// 1*2, so we will put additional brackets to cover for precedence invertion and it will become (1 * 2) ^
|
||||
// 1*2, so we will put additional brackets to cover for precedence inversion and it will become (1 * 2) ^
|
||||
// Here * is m_nPrevOpCode, m_currentVal is 2 (by 1*2), m_nLastCom is +, m_nOpCode is ^
|
||||
if (m_fPrecedence && 0 != m_nPrevOpCode)
|
||||
{
|
||||
nPrev = NPrecedenceOfOp(m_nPrevOpCode);
|
||||
nx = NPrecedenceOfOp(m_nLastCom);
|
||||
ni = NPrecedenceOfOp(m_nOpCode);
|
||||
if (nx <= nPrev && ni > nPrev) // condition for Precedence Invertion
|
||||
if (nx <= nPrev && ni > nPrev) // condition for Precedence Inversion
|
||||
{
|
||||
fPrecInvToHigher = true;
|
||||
m_nPrevOpCode = 0; // Once the precedence invertion has put additional brackets, its no longer required
|
||||
m_nPrevOpCode = 0; // Once the precedence inversion has put additional brackets, its no longer required
|
||||
}
|
||||
}
|
||||
m_HistoryCollector.ChangeLastBinOp(m_nOpCode, fPrecInvToHigher);
|
||||
@@ -233,7 +233,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
|
||||
m_precedenceVals[m_precedenceOpCount] = m_lastVal;
|
||||
|
||||
m_nPrecOp[m_precedenceOpCount] = m_nOpCode;
|
||||
m_HistoryCollector.PushLastOpndStart(); // Eg. 1 + 2 *, Need to remember the start of 2 to do Precedence invertion if need to
|
||||
m_HistoryCollector.PushLastOpndStart(); // Eg. 1 + 2 *, Need to remember the start of 2 to do Precedence inversion if need to
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -264,10 +264,10 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
|
||||
m_lastVal = m_precedenceVals[m_precedenceOpCount];
|
||||
|
||||
nx = NPrecedenceOfOp(m_nOpCode);
|
||||
// Precedence Invertion Higher to lower can happen which needs explicit enclosure of brackets
|
||||
// Precedence Inversion Higher to lower can happen which needs explicit enclosure of brackets
|
||||
// Eg. 1 + 2 * Or 3 Or. We would have pushed 1+ before, and now last + forces 2 Or 3 to be evaluated
|
||||
// because last Or is less or equal to first + (after 1). But we see that 1+ is in stack and we evaluated to 2 Or 3
|
||||
// This is precedence invertion happenned because of operator changed in between. We put extra brackets like
|
||||
// This is precedence inversion happened because of operator changed in between. We put extra brackets like
|
||||
// 1 + (2 Or 3)
|
||||
if (ni <= nx)
|
||||
{
|
||||
@@ -436,7 +436,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// automatic closing of all the parenthesis to get a meaning ful result as well as ensure data integrity
|
||||
// automatic closing of all the parenthesis to get a meaningful result as well as ensure data integrity
|
||||
m_nTempCom = m_nLastCom; // Put back this last saved command to the prev state so ) can be handled properly
|
||||
ProcessCommand(IDC_CLOSEP);
|
||||
m_nLastCom = m_nTempCom; // Actually this is IDC_CLOSEP
|
||||
@@ -445,7 +445,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
|
||||
|
||||
if (!m_bNoPrevEqu)
|
||||
{
|
||||
// It is possible now unary op changed the num in screen, but still m_lastVal hasnt changed.
|
||||
// It is possible now unary op changed the num in screen, but still m_lastVal hasn't changed.
|
||||
m_lastVal = m_currentVal;
|
||||
}
|
||||
|
||||
@@ -502,7 +502,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
|
||||
m_nOpCode = m_nPrecOp[--m_precedenceOpCount];
|
||||
m_lastVal = m_precedenceVals[m_precedenceOpCount];
|
||||
|
||||
// Precedence Invertion check
|
||||
// Precedence Inversion check
|
||||
ni = NPrecedenceOfOp(m_nPrevOpCode);
|
||||
nx = NPrecedenceOfOp(m_nOpCode);
|
||||
if (ni <= nx)
|
||||
@@ -540,7 +540,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
|
||||
// -IF- the Paren holding array is full and we try to add a paren
|
||||
// -OR- the paren holding array is empty and we try to remove a
|
||||
// paren
|
||||
// -OR- the the precidence holding array is full
|
||||
// -OR- the precedence holding array is full
|
||||
if ((m_openParenCount >= MAXPRECDEPTH && nx) || (!m_openParenCount && !nx)
|
||||
|| ((m_precedenceOpCount >= MAXPRECDEPTH && m_nPrecOp[m_precedenceOpCount - 1] != 0)))
|
||||
{
|
||||
@@ -612,7 +612,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
|
||||
|
||||
m_HistoryCollector.AddCloseBraceToHistory();
|
||||
|
||||
// Now get back the operation and opcode at the begining of this parenthesis pair
|
||||
// Now get back the operation and opcode at the beginning of this parenthesis pair
|
||||
|
||||
m_openParenCount -= 1;
|
||||
m_lastVal = m_parenVals[m_openParenCount];
|
||||
@@ -796,7 +796,7 @@ void CCalcEngine::CheckAndAddLastBinOpToHistory(bool addToHistory)
|
||||
{
|
||||
if (m_HistoryCollector.FOpndAddedToHistory())
|
||||
{
|
||||
// if lasttime opnd was added but the last command was not a binary operator, then it must have come
|
||||
// if last time opnd was added but the last command was not a binary operator, then it must have come
|
||||
// from commands which add the operand, like unary operator. So history at this is showing 1 + sqrt(4)
|
||||
// but in reality the sqrt(4) is getting replaced by new number (may be unary op, or MR or SUM etc.)
|
||||
// So erase the last operand
|
||||
@@ -827,7 +827,7 @@ void CCalcEngine::CheckAndAddLastBinOpToHistory(bool addToHistory)
|
||||
}
|
||||
|
||||
// change the display area from a static text to an editbox, which has the focus can make
|
||||
// Magnifer (Accessibility tool) work
|
||||
// Magnifier (Accessibility tool) work
|
||||
void CCalcEngine::SetPrimaryDisplay(const wstring& szText, bool isError)
|
||||
{
|
||||
if (m_pCalcDisplay != nullptr)
|
||||
@@ -848,8 +848,8 @@ void CCalcEngine::DisplayAnnounceBinaryOperator()
|
||||
}
|
||||
|
||||
// Unary operator Function Name table Element
|
||||
// since unary operators button names are'nt exactly friendly for history purpose,
|
||||
// we have this seperate table to get its localized name and for its Inv function if it exists.
|
||||
// since unary operators button names aren't exactly friendly for history purpose,
|
||||
// we have this separate table to get its localized name and for its Inv function if it exists.
|
||||
typedef struct
|
||||
{
|
||||
int idsFunc; // index of string for the unary op function. Can be NULL, in which case it same as button name
|
||||
@@ -905,7 +905,7 @@ wstring_view CCalcEngine::OpCodeToUnaryString(int nOpCode, bool fInv, ANGLE_TYPE
|
||||
return GetString(IDS_DEGREES);
|
||||
}
|
||||
|
||||
// Correct the trigometric functions with type of angle argument they take
|
||||
// Correct the trigonometric functions with type of angle argument they take
|
||||
if (ANGLE_RAD == angletype)
|
||||
{
|
||||
switch (nOpCode)
|
||||
@@ -963,7 +963,7 @@ wstring_view CCalcEngine::OpCodeToUnaryString(int nOpCode, bool fInv, ANGLE_TYPE
|
||||
|
||||
//
|
||||
// Sets the Angle Mode for special unary op IDC's which are used to index to the table rgUfne
|
||||
// and returns the equivalent plain IDC for trignometric function. If it isnt a trignometric function
|
||||
// and returns the equivalent plain IDC for trigonometric function. If it isn't a trigonometric function
|
||||
// returns the passed in idc itself.
|
||||
int CCalcEngine::IdcSetAngleTypeDecMode(int idc)
|
||||
{
|
||||
@@ -1047,7 +1047,7 @@ wstring CCalcEngine::GetStringForDisplay(Rational const& rat, uint32_t radix)
|
||||
bool fMsb = ((w64Bits >> (m_dwWordBitWidth - 1)) & 1);
|
||||
if ((radix == 10) && fMsb)
|
||||
{
|
||||
// If high bit is set, then get the decimal number in negative 2's compl form.
|
||||
// If high bit is set, then get the decimal number in negative 2's complement form.
|
||||
tempRat = -((tempRat ^ m_chopNumbers[m_numwidth]) + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/****************************Module*Header***********************************\
|
||||
* Module Name: SCIDISP.C
|
||||
*
|
||||
* Module Descripton:
|
||||
* Module Description:
|
||||
*
|
||||
* Warnings:
|
||||
*
|
||||
@@ -116,7 +116,7 @@ void CCalcEngine::DisplayNum(void)
|
||||
m_numberString = GetStringForDisplay(m_currentVal, m_radix);
|
||||
}
|
||||
|
||||
// Displayed number can go thru transformation. So copy it after transformation
|
||||
// Displayed number can go through transformation. So copy it after transformation
|
||||
gldPrevious.value = m_currentVal;
|
||||
|
||||
if ((m_radix == 10) && IsNumberInvalid(m_numberString, MAX_EXPONENT, m_precision, m_radix))
|
||||
|
||||
@@ -13,7 +13,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RADIX_TYPE radixtype, NUM_WIDTH numwid
|
||||
{
|
||||
// When in integer mode, the number is represented in 2's complement form. When a bit width is changing, we can
|
||||
// change the number representation back to sign, abs num form in ratpak. Soon when display sees this, it will
|
||||
// convert to 2's complement form, but this time all high bits will be propogated. Eg. -127, in byte mode is
|
||||
// convert to 2's complement form, but this time all high bits will be propagated. Eg. -127, in byte mode is
|
||||
// represented as 1000,0001. This puts it back as sign=-1, 01111111 . But DisplayNum will see this and convert it
|
||||
// back to 1111,1111,1000,0001 when in Word mode.
|
||||
if (m_fIntegerMode)
|
||||
@@ -42,7 +42,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RADIX_TYPE radixtype, NUM_WIDTH numwid
|
||||
m_dwWordBitWidth = DwWordBitWidthFromeNumWidth(numwidth);
|
||||
}
|
||||
|
||||
// inform ratpak that a change in base or precision has occured
|
||||
// inform ratpak that a change in base or precision has occurred
|
||||
BaseOrPrecisionChanged();
|
||||
|
||||
// display the correct number for the new state (ie convert displayed
|
||||
@@ -130,8 +130,8 @@ int CCalcEngine::QuickLog2(int iNum)
|
||||
// word size, and base. This number is conservative towards the small side
|
||||
// such that there may be some extra bits left over. For example, base 8 requires 3 bits per digit.
|
||||
// A word size of 32 bits allows for 10 digits with a remainder of two bits. Bases
|
||||
// that require variable numnber of bits (non-power-of-two bases) are approximated
|
||||
// by the next highest power-of-two base (again, to be conservative and gaurentee
|
||||
// that require variable number of bits (non-power-of-two bases) are approximated
|
||||
// by the next highest power-of-two base (again, to be conservative and guarantee
|
||||
// there will be no over flow verse the current word size for numbers entered).
|
||||
// Base 10 is a special case and always uses the base 10 precision (m_nPrecisionSav).
|
||||
void CCalcEngine::UpdateMaxIntDigits()
|
||||
@@ -160,10 +160,10 @@ void CCalcEngine::ChangeBaseConstants(uint32_t radix, int maxIntDigits, int32_t
|
||||
{
|
||||
if (10 == radix)
|
||||
{
|
||||
ChangeConstants(radix, precision); // Base 10 precesion for internal computing still needs to be 32, to
|
||||
// take care of decimals preceisly. For eg. to get the HI word of a qword, we do a rsh, which depends on getting
|
||||
// 18446744073709551615 / 4294967296 = 4294967295.9999917... This is important it works this and doesnt reduce
|
||||
// the precision to number of digits allowed to enter. In otherwords precision and # of allowed digits to be
|
||||
ChangeConstants(radix, precision); // Base 10 precision for internal computing still needs to be 32, to
|
||||
// take care of decimals precisely. For eg. to get the HI word of a qword, we do a rsh, which depends on getting
|
||||
// 18446744073709551615 / 4294967296 = 4294967295.9999917... This is important it works this and doesn't reduce
|
||||
// the precision to number of digits allowed to enter. In other words, precision and # of allowed digits to be
|
||||
// entered are different.
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user