Apply spell check (#41)

This commit is contained in:
Matt Cooley 2019-02-26 20:41:04 -08:00 committed by GitHub
parent 81a6f59430
commit 28f982a6e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 131 additions and 131 deletions

View File

@ -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) 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 // 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)); auto chDigit = static_cast<wchar_t>((value < 10) ? (L'0' + value) : (L'A' + value - 10));
CalcNumSec* pNumSec; CalcNumSec* pNumSec;
@ -80,7 +80,7 @@ bool CalcInput::TryAddDigit(unsigned int value, uint32_t radix, bool isIntegerMo
maxCount++; maxCount++;
} }
// First leading 0 is not counted in input restriction as the output can be of that form // 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. // 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') if (!pNumSec->IsEmpty() && pNumSec->value.front() == L'0')
{ {

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
#include "pch.h" #include "pch.h"
@ -14,8 +14,8 @@ bool IsBinOpCode(WPARAM opCode)
return IsOpInRange(opCode, IDC_AND, IDC_PWR); 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 // 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 themself or not needing this // of it and catch it themselves or not needing this
bool IsUnaryOpCode(WPARAM opCode) bool IsUnaryOpCode(WPARAM opCode)
{ {
return IsOpInRange(opCode, IDC_UNARYFIRST, IDC_UNARYLAST); return IsOpInRange(opCode, IDC_UNARYFIRST, IDC_UNARYLAST);

View File

@ -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 *) // 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) ^) // 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)
{ {
@ -196,7 +196,7 @@ bool CHistoryCollector::FOpndAddedToHistory()
// AddUnaryOpToHistory // 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) // 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) void CHistoryCollector::AddUnaryOpToHistory(int nOpCode, bool fInv, ANGLE_TYPE angletype)

View File

@ -4,7 +4,7 @@
/****************************Module*Header***********************************\ /****************************Module*Header***********************************\
* Module Name: SCICOMM.C * Module Name: SCICOMM.C
* *
* Module Descripton: * Module Description:
* *
* Warnings: * Warnings:
* *
@ -28,8 +28,8 @@ using namespace CalcEngine;
// NPrecedenceOfOp // NPrecedenceOfOp
// //
// returns a virtual number for precendence for the operator. We expect binary operator only, otherwise the lowest number // 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 precendence of the operator. // 0 is returned. Higher the number, higher the precedence of the operator.
INT NPrecedenceOfOp(int nopCode) INT NPrecedenceOfOp(int nopCode)
{ {
static BYTE rgbPrec[] = { 0,0, IDC_OR,0, IDC_XOR,0, IDC_AND,1, static BYTE rgbPrec[] = { 0,0, IDC_OR,0, IDC_XOR,0, IDC_AND,1,
@ -53,12 +53,12 @@ INT NPrecedenceOfOp(int nopCode)
// HandleErrorCommand // 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 // 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) void CCalcEngine::HandleErrorCommand(WPARAM idc)
{ {
if (!IsGuiSettingOpCode(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; m_nTempCom = m_nLastCom;
} }
} }
@ -184,23 +184,23 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
if (IsBinOpCode(m_nLastCom)) if (IsBinOpCode(m_nLastCom))
{ {
INT nPrev; 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; 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 // 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 ^ // Here * is m_nPrevOpCode, m_currentVal is 2 (by 1*2), m_nLastCom is +, m_nOpCode is ^
if (m_fPrecedence && 0 != m_nPrevOpCode) if (m_fPrecedence && 0 != m_nPrevOpCode)
{ {
nPrev = NPrecedenceOfOp(m_nPrevOpCode); nPrev = NPrecedenceOfOp(m_nPrevOpCode);
nx = NPrecedenceOfOp(m_nLastCom); nx = NPrecedenceOfOp(m_nLastCom);
ni = NPrecedenceOfOp(m_nOpCode); ni = NPrecedenceOfOp(m_nOpCode);
if (nx <= nPrev && ni > nPrev) // condition for Precedence Invertion if (nx <= nPrev && ni > nPrev) // condition for Precedence Inversion
{ {
fPrecInvToHigher = true; 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); m_HistoryCollector.ChangeLastBinOp(m_nOpCode, fPrecInvToHigher);
@ -233,7 +233,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
m_precedenceVals[m_precedenceOpCount] = m_lastVal; m_precedenceVals[m_precedenceOpCount] = m_lastVal;
m_nPrecOp[m_precedenceOpCount] = m_nOpCode; 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 else
{ {
@ -264,10 +264,10 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
m_lastVal = m_precedenceVals[m_precedenceOpCount]; m_lastVal = m_precedenceVals[m_precedenceOpCount];
nx = NPrecedenceOfOp(m_nOpCode); 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 // 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 // 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) // 1 + (2 Or 3)
if (ni <= nx) if (ni <= nx)
{ {
@ -436,7 +436,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
{ {
break; 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 m_nTempCom = m_nLastCom; // Put back this last saved command to the prev state so ) can be handled properly
ProcessCommand(IDC_CLOSEP); ProcessCommand(IDC_CLOSEP);
m_nLastCom = m_nTempCom; // Actually this is IDC_CLOSEP m_nLastCom = m_nTempCom; // Actually this is IDC_CLOSEP
@ -445,7 +445,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
if (!m_bNoPrevEqu) 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; m_lastVal = m_currentVal;
} }
@ -502,7 +502,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
m_nOpCode = m_nPrecOp[--m_precedenceOpCount]; m_nOpCode = m_nPrecOp[--m_precedenceOpCount];
m_lastVal = m_precedenceVals[m_precedenceOpCount]; m_lastVal = m_precedenceVals[m_precedenceOpCount];
// Precedence Invertion check // Precedence Inversion check
ni = NPrecedenceOfOp(m_nPrevOpCode); ni = NPrecedenceOfOp(m_nPrevOpCode);
nx = NPrecedenceOfOp(m_nOpCode); nx = NPrecedenceOfOp(m_nOpCode);
if (ni <= nx) 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 // -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 // -OR- the paren holding array is empty and we try to remove a
// paren // paren
// -OR- the the precidence holding array is full // -OR- the precedence holding array is full
if ((m_openParenCount >= MAXPRECDEPTH && nx) || (!m_openParenCount && !nx) if ((m_openParenCount >= MAXPRECDEPTH && nx) || (!m_openParenCount && !nx)
|| ((m_precedenceOpCount >= MAXPRECDEPTH && m_nPrecOp[m_precedenceOpCount - 1] != 0))) || ((m_precedenceOpCount >= MAXPRECDEPTH && m_nPrecOp[m_precedenceOpCount - 1] != 0)))
{ {
@ -612,7 +612,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
m_HistoryCollector.AddCloseBraceToHistory(); 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_openParenCount -= 1;
m_lastVal = m_parenVals[m_openParenCount]; m_lastVal = m_parenVals[m_openParenCount];
@ -796,7 +796,7 @@ void CCalcEngine::CheckAndAddLastBinOpToHistory(bool addToHistory)
{ {
if (m_HistoryCollector.FOpndAddedToHistory()) 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) // 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.) // 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 // 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 // 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) void CCalcEngine::SetPrimaryDisplay(const wstring& szText, bool isError)
{ {
if (m_pCalcDisplay != nullptr) if (m_pCalcDisplay != nullptr)
@ -848,8 +848,8 @@ void CCalcEngine::DisplayAnnounceBinaryOperator()
} }
// Unary operator Function Name table Element // Unary operator Function Name table Element
// since unary operators button names are'nt exactly friendly for history purpose, // since unary operators button names aren't exactly friendly for history purpose,
// we have this seperate table to get its localized name and for its Inv function if it exists. // we have this separate table to get its localized name and for its Inv function if it exists.
typedef struct typedef struct
{ {
int idsFunc; // index of string for the unary op function. Can be NULL, in which case it same as button name 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); 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) if (ANGLE_RAD == angletype)
{ {
switch (nOpCode) 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 // 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. // returns the passed in idc itself.
int CCalcEngine::IdcSetAngleTypeDecMode(int idc) 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); bool fMsb = ((w64Bits >> (m_dwWordBitWidth - 1)) & 1);
if ((radix == 10) && fMsb) 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); tempRat = -((tempRat ^ m_chopNumbers[m_numwidth]) + 1);
} }

View File

@ -4,7 +4,7 @@
/****************************Module*Header***********************************\ /****************************Module*Header***********************************\
* Module Name: SCIDISP.C * Module Name: SCIDISP.C
* *
* Module Descripton: * Module Description:
* *
* Warnings: * Warnings:
* *
@ -116,7 +116,7 @@ void CCalcEngine::DisplayNum(void)
m_numberString = GetStringForDisplay(m_currentVal, m_radix); 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; gldPrevious.value = m_currentVal;
if ((m_radix == 10) && IsNumberInvalid(m_numberString, MAX_EXPONENT, m_precision, m_radix)) if ((m_radix == 10) && IsNumberInvalid(m_numberString, MAX_EXPONENT, m_precision, m_radix))

View File

@ -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 // 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 // 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 // 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. // back to 1111,1111,1000,0001 when in Word mode.
if (m_fIntegerMode) if (m_fIntegerMode)
@ -42,7 +42,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RADIX_TYPE radixtype, NUM_WIDTH numwid
m_dwWordBitWidth = DwWordBitWidthFromeNumWidth(numwidth); 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(); BaseOrPrecisionChanged();
// display the correct number for the new state (ie convert displayed // 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 // 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. // 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 // 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 // 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 gaurentee // 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). // 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). // Base 10 is a special case and always uses the base 10 precision (m_nPrecisionSav).
void CCalcEngine::UpdateMaxIntDigits() void CCalcEngine::UpdateMaxIntDigits()
@ -160,10 +160,10 @@ void CCalcEngine::ChangeBaseConstants(uint32_t radix, int maxIntDigits, int32_t
{ {
if (10 == radix) if (10 == radix)
{ {
ChangeConstants(radix, precision); // Base 10 precesion for internal computing still needs to be 32, to ChangeConstants(radix, precision); // Base 10 precision 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 // 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 doesnt reduce // 18446744073709551615 / 4294967296 = 4294967295.9999917... This is important it works this and doesn't reduce
// the precision to number of digits allowed to enter. In otherwords precision and # of allowed digits to be // the precision to number of digits allowed to enter. In other words, precision and # of allowed digits to be
// entered are different. // entered are different.
} }
else else

View File

@ -600,8 +600,8 @@ namespace CalculationManager
} }
/// <summary> /// <summary>
/// Helper function that selects a memeory from the vector and set it to CCalcEngine /// Helper function that selects a memory from the vector and set it to CCalcEngine
/// Saved RAT number needs to be copied and passed in, as CCalcEngine destoried the passed in RAT /// Saved RAT number needs to be copied and passed in, as CCalcEngine destroyed the passed in RAT
/// </summary> /// </summary>
/// <param name="indexOfMemeory">Index of the target memory</param> /// <param name="indexOfMemeory">Index of the target memory</param>
void CalculatorManager::MemorizedNumberSelect(_In_ unsigned int indexOfMemory) void CalculatorManager::MemorizedNumberSelect(_In_ unsigned int indexOfMemory)
@ -615,7 +615,7 @@ namespace CalculationManager
/// <summary> /// <summary>
/// Helper function that needs to be executed when memory is modified /// Helper function that needs to be executed when memory is modified
/// When memory is modified, destory the old RAT and put the new RAT in vector /// When memory is modified, destroy the old RAT and put the new RAT in vector
/// </summary> /// </summary>
/// <param name="indexOfMemeory">Index of the target memory</param> /// <param name="indexOfMemeory">Index of the target memory</param>
void CalculatorManager::MemorizedNumberChanged(_In_ unsigned int indexOfMemory) void CalculatorManager::MemorizedNumberChanged(_In_ unsigned int indexOfMemory)

View File

@ -60,7 +60,7 @@ namespace CalculationManager
static const unsigned int m_maximumMemorySize = 100; static const unsigned int m_maximumMemorySize = 100;
// For persistance // For persistence
std::vector<unsigned char> m_savedCommands; std::vector<unsigned char> m_savedCommands;
std::vector<long> m_savedPrimaryValue; std::vector<long> m_savedPrimaryValue;
std::vector<long> m_serializedMemory; std::vector<long> m_serializedMemory;

View File

@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
/****************************Module*Header*********************************** /****************************Module*Header***********************************
* Module Name: CCommand.h * Module Name: CCommand.h
* *
* Module Descripton: * Module Description:
* Resource ID's for the Engine Commands exposed. * Resource ID's for the Engine Commands exposed.
* *
* Warnings: * Warnings:

View File

@ -5,7 +5,7 @@
/****************************Module*Header***********************************\ /****************************Module*Header***********************************\
* Module Name: CalcEngine.h * Module Name: CalcEngine.h
* *
* Module Descripton: * Module Description:
* The class definition for the Calculator's engine class CCalcEngine * The class definition for the Calculator's engine class CCalcEngine
* *
* Warnings: * Warnings:
@ -69,7 +69,7 @@ public:
wchar_t DecimalSeparator() const; wchar_t DecimalSeparator() const;
// Static methods for the instance // Static methods for the instance
static void InitialOneTimeOnlySetup(CalculationManager::IResourceProvider& resourceProvider); // Once per load time to call to intialize all shared global variables static void InitialOneTimeOnlySetup(CalculationManager::IResourceProvider& resourceProvider); // Once per load time to call to initialize all shared global variables
// returns the ptr to string representing the operator. Mostly same as the button, but few special cases for x^y etc. // returns the ptr to string representing the operator. Mostly same as the button, but few special cases for x^y etc.
static std::wstring_view GetString(int ids) { return s_engineStrings[ids]; } static std::wstring_view GetString(int ids) { return s_engineStrings[ids]; }
static std::wstring_view OpCodeToString(int nOpCode) { return GetString(IdStrFromCmdId(nOpCode)); } static std::wstring_view OpCodeToString(int nOpCode) { return GetString(IdStrFromCmdId(nOpCode)); }
@ -82,10 +82,10 @@ private:
CalculationManager::IResourceProvider* const m_resourceProvider; CalculationManager::IResourceProvider* const m_resourceProvider;
int m_nOpCode; /* ID value of operation. */ int m_nOpCode; /* ID value of operation. */
int m_nPrevOpCode; // opcode which computed the number in m_currentVal. 0 if it is already bracketed or plain number or int m_nPrevOpCode; // opcode which computed the number in m_currentVal. 0 if it is already bracketed or plain number or
// if it hasnt yet been computed // if it hasn't yet been computed
bool m_bChangeOp; /* Flag for changing operation. */ bool m_bChangeOp; /* Flag for changing operation. */
bool m_bRecord; // Global mode: recording or displaying bool m_bRecord; // Global mode: recording or displaying
bool m_bSetCalcState; //Falg for setting teh engine result state bool m_bSetCalcState; //Flag for setting the engine result state
CalcEngine::CalcInput m_input; // Global calc input object for decimal strings CalcEngine::CalcInput m_input; // Global calc input object for decimal strings
eNUMOBJ_FMT m_nFE; /* Scientific notation conversion flag. */ eNUMOBJ_FMT m_nFE; /* Scientific notation conversion flag. */
CalcEngine::Rational m_maxTrigonometricNum; CalcEngine::Rational m_maxTrigonometricNum;

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
#pragma once #pragma once
@ -6,8 +6,8 @@
bool IsOpInRange(WPARAM op, uint32_t x, uint32_t y); bool IsOpInRange(WPARAM op, uint32_t x, uint32_t y);
bool IsBinOpCode(WPARAM opCode); bool IsBinOpCode(WPARAM opCode);
// WARNING: IDC_SIGN is a special unary op but still this doesnt catch this. Caller has to be aware // 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 themself or not needing this // of it and catch it themselves or not needing this
bool IsUnaryOpCode(WPARAM opCode); bool IsUnaryOpCode(WPARAM opCode);
bool IsDigitOpCode(WPARAM opCode); bool IsDigitOpCode(WPARAM opCode);
bool IsGuiSettingOpCode(WPARAM opCode); bool IsGuiSettingOpCode(WPARAM opCode);

View File

@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
/****************************Module*Header*********************************** /****************************Module*Header***********************************
* Module Name: EngineStrings.h * Module Name: EngineStrings.h
* *
* Module Descripton: * Module Description:
* Resource String ID's for the private strings used by Engine. Internal to Engine related code * Resource String ID's for the private strings used by Engine. Internal to Engine related code
* not required by the clients * not required by the clients
* *

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
#pragma once #pragma once
@ -11,7 +11,7 @@
static constexpr size_t MAXPRECDEPTH = 25; static constexpr size_t MAXPRECDEPTH = 25;
// Helper class really a internal class to CCalcEngine, to accumulate each history line of text by collecting the // Helper class really a internal class to CCalcEngine, to accumulate each history line of text by collecting the
// operands, operator, unary operator etc. Since it is a seperate entity, it can be unit tested on its own but does // operands, operator, unary operator etc. Since it is a separate entity, it can be unit tested on its own but does
// rely on CCalcEngine calling it in appropriate order. // rely on CCalcEngine calling it in appropriate order.
class CHistoryCollector { class CHistoryCollector {
public: public:
@ -38,7 +38,7 @@ private:
std::shared_ptr<IHistoryDisplay> m_pHistoryDisplay; std::shared_ptr<IHistoryDisplay> m_pHistoryDisplay;
ICalcDisplay *m_pCalcDisplay; ICalcDisplay *m_pCalcDisplay;
int m_iCurLineHistStart; // index of the begginning of the current equation int m_iCurLineHistStart; // index of the beginning of the current equation
// a sort of state, set to the index before 2 after 2 in the expression 2 + 3 say. Useful for auto correct portion of history and for // a sort of state, set to the index before 2 after 2 in the expression 2 + 3 say. Useful for auto correct portion of history and for
// attaching the unary op around the last operand // attaching the unary op around the last operand
int m_lastOpStartIndex; // index of the beginning of the last operand added to the history int m_lastOpStartIndex; // index of the beginning of the last operand added to the history

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
// CalcErr.h // CalcErr.h
@ -6,7 +6,7 @@
// Defines the error codes thrown by ratpak and caught by Calculator // Defines the error codes thrown by ratpak and caught by Calculator
// //
// //
// Ratpak errors are 32 bit values layed out as follows: // Ratpak errors are 32 bit values laid out as follows:
// //
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
@ -31,8 +31,8 @@
// //
// Code - is the actual error code // Code - is the actual error code
// //
// This format is based losely on an OLE HRESULT and is compatible with the // This format is based loosely on an OLE HRESULT and is compatible with the
// SUCCEEDED and FAILED marcos as well as the HRESULT_CODE macro // SUCCEEDED and FAILED macros as well as the HRESULT_CODE macro
// CALC_E_DIVIDEBYZERO // CALC_E_DIVIDEBYZERO
// //

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -42,7 +42,7 @@ void __inline mulnumx( PNUMBER *pa, PNUMBER b )
// If b is not one we multiply // If b is not one we multiply
if ( (*pa)->cdigit > 1 || (*pa)->mant[0] != 1 || (*pa)->exp != 0 ) if ( (*pa)->cdigit > 1 || (*pa)->mant[0] != 1 || (*pa)->exp != 0 )
{ {
// pa and b are both nonone. // pa and b are both non-one.
_mulnumx( pa, b ); _mulnumx( pa, b );
} }
else else
@ -71,7 +71,7 @@ void __inline mulnumx( PNUMBER *pa, PNUMBER b )
// //
// DESCRIPTION: Does the number equivalent of *pa *= b. // DESCRIPTION: Does the number equivalent of *pa *= b.
// Assumes the base is BASEX of both numbers. This algorithm is the // Assumes the base is BASEX of both numbers. This algorithm is the
// same one you learned in gradeschool, except the base isn't 10 it's // same one you learned in grade school, except the base isn't 10 it's
// BASEX. // BASEX.
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -148,7 +148,7 @@ void _mulnumx( PNUMBER *pa, PNUMBER b )
} }
} }
// prevent different kinds of zeros, by stripping leading duplicate zeroes. // prevent different kinds of zeros, by stripping leading duplicate zeros.
// digits are in order of increasing significance. // digits are in order of increasing significance.
while ( c->cdigit > 1 && c->mant[c->cdigit-1] == 0 ) while ( c->cdigit > 1 && c->mant[c->cdigit-1] == 0 )
{ {
@ -342,7 +342,7 @@ void _divnumx( PNUMBER *pa, PNUMBER b, int32_t precision)
if ( !cdigits ) if ( !cdigits )
{ {
// A zero, make sure no wierd exponents creep in // A zero, make sure no weird exponents creep in
c->exp = 0; c->exp = 0;
c->cdigit = 1; c->cdigit = 1;
} }
@ -351,7 +351,7 @@ void _divnumx( PNUMBER *pa, PNUMBER b, int32_t precision)
c->cdigit = cdigits; c->cdigit = cdigits;
c->exp -= cdigits; c->exp -= cdigits;
// prevent different kinds of zeros, by stripping leading duplicate // prevent different kinds of zeros, by stripping leading duplicate
// zeroes. digits are in order of increasing significance. // zeros. digits are in order of increasing significance.
while ( c->cdigit > 1 && c->mant[c->cdigit-1] == 0 ) while ( c->cdigit > 1 && c->mant[c->cdigit-1] == 0 )
{ {
c->cdigit--; c->cdigit--;

View File

@ -33,7 +33,7 @@ long g_ratio; // int(log(2L^BASEXPWR)/log(radix))
// Default decimal separator // Default decimal separator
wchar_t g_decimalSeparator = L'.'; wchar_t g_decimalSeparator = L'.';
// Used to strip trailing zeroes, and prevent combinatorial explosions // Used to strip trailing zeros, and prevent combinatorial explosions
bool stripzeroesnum(_Inout_ PNUMBER pnum, long starting); bool stripzeroesnum(_Inout_ PNUMBER pnum, long starting);
void SetDecimalSeparator(wchar_t decimalSeparator) void SetDecimalSeparator(wchar_t decimalSeparator)
@ -121,7 +121,7 @@ void _destroyrat( _In_ PRAT prat )
// //
// RETURN: pointer to a number // RETURN: pointer to a number
// //
// DESCRIPTION: allocates and zeroes out number type. // DESCRIPTION: allocates and zeros out number type.
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -480,7 +480,7 @@ PRAT StringToRat(bool mantissaIsNegative, wstring_view mantissa, bool exponentIs
// ZR '0' // ZR '0'
// NZ '1'..'9' 'A'..'Z' 'a'..'z' '@' '_' // NZ '1'..'9' 'A'..'Z' 'a'..'z' '@' '_'
// SG '+' '-' // SG '+' '-'
// EX 'e' '^' e is used for radix 10, ^ for all other radixs. // EX 'e' '^' e is used for radix 10, ^ for all other radixes.
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static constexpr uint8_t DP = 0; static constexpr uint8_t DP = 0;
@ -911,8 +911,8 @@ unsigned long rattoUlong( _In_ PRAT prat, uint32_t radix, int32_t precision)
// DESCRIPTION: returns the 64 bit (irrespective of which processor this is running in) representation of the // DESCRIPTION: returns the 64 bit (irrespective of which processor this is running in) representation of the
// number input. Assumes that the number is in the internal // number input. Assumes that the number is in the internal
// base. Can throw exception if the number exceeds 2^64 // base. Can throw exception if the number exceeds 2^64
// Implementation by getting the HI & LO 32 bit words and concating them, as the // Implementation by getting the HI & LO 32 bit words and concatenating them, as the
// internal base choosen happens to be 2^32, this is easier. // internal base chosen happens to be 2^32, this is easier.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
ULONGLONG rattoUlonglong( _In_ PRAT prat, uint32_t radix, int32_t precision) ULONGLONG rattoUlonglong( _In_ PRAT prat, uint32_t radix, int32_t precision)
@ -981,7 +981,7 @@ long numtolong( _In_ PNUMBER pnum, uint32_t radix )
// //
// RETURN: true if stripping done, modifies number in place. // RETURN: true if stripping done, modifies number in place.
// //
// DESCRIPTION: Strips off trailing zeroes. // DESCRIPTION: Strips off trailing zeros.
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1001,7 +1001,7 @@ bool stripzeroesnum(_Inout_ PNUMBER pnum, long starting)
cdigits = starting; cdigits = starting;
} }
// Check we haven't gone too far, and we are still looking at zeroes. // Check we haven't gone too far, and we are still looking at zeros.
while ( ( cdigits > 0 ) && !(*pmant) ) while ( ( cdigits > 0 ) && !(*pmant) )
{ {
// move to next significant digit and keep track of digits we can // move to next significant digit and keep track of digits we can
@ -1011,7 +1011,7 @@ bool stripzeroesnum(_Inout_ PNUMBER pnum, long starting)
fstrip = true; fstrip = true;
} }
// If there are zeroes to remove. // If there are zeros to remove.
if ( fstrip ) if ( fstrip )
{ {
// Remove them. // Remove them.
@ -1061,7 +1061,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
// 10 for maximum exponent size. // 10 for maximum exponent size.
int cchNum = (precision + 16); int cchNum = (precision + 16);
// If there is a chance a round has to occour, round. // If there is a chance a round has to occur, round.
// - if number is zero no rounding // - if number is zero no rounding
// - if number of digits is less than the maximum output no rounding // - if number of digits is less than the maximum output no rounding
PNUMBER round = nullptr; PNUMBER round = nullptr;
@ -1087,7 +1087,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
if (format == FMT_FLOAT) if (format == FMT_FLOAT)
{ {
// Figure out if the exponent will fill more space than the nonexponent field. // Figure out if the exponent will fill more space than the non-exponent field.
if ((length - exponent > precision) || (exponent > precision + 3)) if ((length - exponent > precision) || (exponent > precision + 3))
{ {
if (exponent >= -MAX_ZEROS_AFTER_DECIMAL) if (exponent >= -MAX_ZEROS_AFTER_DECIMAL)
@ -1097,15 +1097,15 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
} }
else else
{ {
// Case where too many zeroes are to the right or left of the // Case where too many zeros are to the right or left of the
// decimal pt. And we are forced to switch to scientific form. // decimal pt. And we are forced to switch to scientific form.
format = FMT_SCIENTIFIC; format = FMT_SCIENTIFIC;
} }
} }
else if (length + abs(exponent) < precision && round) else if (length + abs(exponent) < precision && round)
{ {
// Minimum loss of precision occours with listing leading zeros // Minimum loss of precision occurs with listing leading zeros
// if we need to make room for zeroes sacrifice some digits. // if we need to make room for zeros sacrifice some digits.
round->exp -= exponent; round->exp -= exponent;
} }
} }
@ -1118,7 +1118,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
if (stripzeroesnum(pnum, offset)) if (stripzeroesnum(pnum, offset))
{ {
// WARNING: nesting/recursion, too much has been changed, need to // WARNING: nesting/recursion, too much has been changed, need to
// refigure format. // re-figure format.
return NumberToString(pnum, oldFormat, radix, precision); return NumberToString(pnum, oldFormat, radix, precision);
} }
} }
@ -1165,7 +1165,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
// Begin building the result string // Begin building the result string
wstringstream resultStream{}; wstringstream resultStream{};
// Make sure negative zeroes aren't allowed. // Make sure negative zeros aren't allowed.
if ((pnum->sign == -1) && (length > 0)) if ((pnum->sign == -1) && (length > 0))
{ {
resultStream << L'-'; resultStream << L'-';
@ -1399,7 +1399,7 @@ PNUMBER longfactnum(long inlong, uint32_t radix)
// ARGUMENTS: // ARGUMENTS:
// long integer to factorialize. // long integer to factorialize.
// long integer representing base of answer. // long integer representing base of answer.
// unsignd long integer for radix // unsigned long integer for radix
// //
// RETURN: Factorial of input in base PNUMBER form. // RETURN: Factorial of input in base PNUMBER form.
// //

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -235,7 +235,7 @@ void log10rat( PRAT *px, int32_t precision)
} }
// //
// return if the given x is even number. The assumption here is its numberator is 1 and we are testing the numerator is // return if the given x is even number. The assumption here is its numerator is 1 and we are testing the numerator is
// even or not // even or not
bool IsEven(PRAT x, uint32_t radix, int32_t precision) bool IsEven(PRAT x, uint32_t radix, int32_t precision)
{ {
@ -291,7 +291,7 @@ void powrat(PRAT *px, PRAT y, uint32_t radix, int32_t precision)
catch (...) catch (...)
{ {
// If calculating the power using numerator/denominator // If calculating the power using numerator/denominator
// failed, fallback to the less accurate method of // failed, fall back to the less accurate method of
// passing in the original y // passing in the original y
powratcomp(px, y, radix, precision); powratcomp(px, y, radix, precision);
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -150,7 +150,7 @@ void _addnum( PNUMBER *pa, PNUMBER b, uint32_t radix)
} }
else else
{ {
// In this particular case an overflow or underflow has occoured // In this particular case an overflow or underflow has occurred
// and all the digits need to be complemented, at one time an // and all the digits need to be complemented, at one time an
// attempt to handle this above was made, it turned out to be much // attempt to handle this above was made, it turned out to be much
// slower on average. // slower on average.
@ -167,7 +167,7 @@ void _addnum( PNUMBER *pa, PNUMBER b, uint32_t radix)
} }
} }
// Remove leading zeroes, remember digits are in order of // Remove leading zeros, remember digits are in order of
// increasing significance. i.e. 100 would be 0,0,1 // increasing significance. i.e. 100 would be 0,0,1
while ( c->cdigit > 1 && *(--pchc) == 0 ) while ( c->cdigit > 1 && *(--pchc) == 0 )
{ {
@ -188,7 +188,7 @@ void _addnum( PNUMBER *pa, PNUMBER b, uint32_t radix)
// //
// DESCRIPTION: Does the number equivalent of *pa *= b. // DESCRIPTION: Does the number equivalent of *pa *= b.
// Assumes radix is the radix of both numbers. This algorithm is the // Assumes radix is the radix of both numbers. This algorithm is the
// same one you learned in gradeschool. // same one you learned in grade school.
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -200,7 +200,7 @@ void __inline mulnum( PNUMBER *pa, PNUMBER b, uint32_t radix)
if ( b->cdigit > 1 || b->mant[0] != 1 || b->exp != 0 ) if ( b->cdigit > 1 || b->mant[0] != 1 || b->exp != 0 )
{ // If b is one we don't multiply exactly. { // If b is one we don't multiply exactly.
if ( (*pa)->cdigit > 1 || (*pa)->mant[0] != 1 || (*pa)->exp != 0 ) if ( (*pa)->cdigit > 1 || (*pa)->mant[0] != 1 || (*pa)->exp != 0 )
{ // pa and b are both nonone. { // pa and b are both non-one.
_mulnum( pa, b, radix); _mulnum( pa, b, radix);
} }
else else
@ -285,7 +285,7 @@ void _mulnum( PNUMBER *pa, PNUMBER b, uint32_t radix)
} }
} }
// prevent different kinds of zeros, by stripping leading duplicate zeroes. // prevent different kinds of zeros, by stripping leading duplicate zeros.
// digits are in order of increasing significance. // digits are in order of increasing significance.
while ( c->cdigit > 1 && c->mant[c->cdigit-1] == 0 ) while ( c->cdigit > 1 && c->mant[c->cdigit-1] == 0 )
{ {

View File

@ -237,7 +237,7 @@ void addrat( PRAT *pa, PRAT b, int32_t precision)
(*pa)->pq = bot; (*pa)->pq = bot;
trimit(pa, precision); trimit(pa, precision);
// Get rid of negative zeroes here. // Get rid of negative zeros here.
(*pa)->pp->sign *= (*pa)->pq->sign; (*pa)->pp->sign *= (*pa)->pq->sign;
(*pa)->pq->sign = 1; (*pa)->pq->sign = 1;
} }

View File

@ -474,7 +474,7 @@ void scale( PRAT *px, PRAT scalefact, uint32_t radix, int32_t precision )
DUPRAT(pret,*px); DUPRAT(pret,*px);
// Logscale is a quick way to tell how much extra precision is needed for // Logscale is a quick way to tell how much extra precision is needed for
// scaleing by scalefact. // scaling by scalefact.
long logscale = g_ratio * ( (pret->pp->cdigit+pret->pp->exp) - long logscale = g_ratio * ( (pret->pp->cdigit+pret->pp->exp) -
(pret->pq->cdigit+pret->pq->exp) ); (pret->pq->cdigit+pret->pq->exp) );
if ( logscale > 0 ) if ( logscale > 0 )
@ -509,7 +509,7 @@ void scale2pi( PRAT *px, uint32_t radix, int32_t precision )
DUPRAT(pret,*px); DUPRAT(pret,*px);
// Logscale is a quick way to tell how much extra precision is needed for // Logscale is a quick way to tell how much extra precision is needed for
// scaleing by 2 pi. // scaling by 2 pi.
long logscale = g_ratio * ( (pret->pp->cdigit+pret->pp->exp) - long logscale = g_ratio * ( (pret->pp->cdigit+pret->pp->exp) -
(pret->pq->cdigit+pret->pq->exp) ); (pret->pq->cdigit+pret->pq->exp) );
if ( logscale > 0 ) if ( logscale > 0 )

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -134,7 +134,7 @@ void sinanglerat( _Inout_ PRAT *pa, ANGLE_TYPE angletype, uint32_t radix, int32_
// //
// ARGUMENTS: x PRAT representation of number to take the cosine of // ARGUMENTS: x PRAT representation of number to take the cosine of
// //
// RETURN: cosin of x in PRAT form. // RETURN: cosine of x in PRAT form.
// //
// EXPLANATION: This uses Taylor series // EXPLANATION: This uses Taylor series
// //

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
#include "pch.h" #include "pch.h"
@ -1024,7 +1024,7 @@ void UnitConverter::Calculate()
} }
/// <summary> /// <summary>
/// Trims out any trailing zeroes or decimals in the given input string /// Trims out any trailing zeros or decimals in the given input string
/// </summary> /// </summary>
/// <param name="input">wstring to trim</param> /// <param name="input">wstring to trim</param>
void UnitConverter::TrimString(wstring& returnString) void UnitConverter::TrimString(wstring& returnString)

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
#pragma once #pragma once
@ -61,7 +61,7 @@ namespace CalculatorApp { namespace Common
} }
} }
// Implementented methods // Implemented methods
virtual bool MoveCurrentTo(Platform::Object^ item) = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentTo virtual bool MoveCurrentTo(Platform::Object^ item) = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentTo
{ {
if (item) if (item)

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
#include "pch.h" #include "pch.h"
@ -23,8 +23,8 @@ int NarratorAnnouncementHostFactory::Initialize()
} }
// For now, there are two type of announcement hosts. // For now, there are two type of announcement hosts.
// We'd prefer to use Notification if it's available and fallback to LiveRegion // We'd prefer to use Notification if it's available and fall back to LiveRegion
// if not. The availabilty of the host depends on the version of the OS the app is running on. // if not. The availability of the host depends on the version of the OS the app is running on.
// When the app switches to min version RS3, the LiveRegionHost can be removed and we will always // When the app switches to min version RS3, the LiveRegionHost can be removed and we will always
// use NotificationHost. // use NotificationHost.
// TODO - MSFT 12735088 // TODO - MSFT 12735088

View File

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
// This class provides the concrete implemenation for the ICalcDisplay interface // This class provides the concrete implementation for the ICalcDisplay interface
// that is declared in the Calculation Manager Library. // that is declared in the Calculation Manager Library.
#include "pch.h" #include "pch.h"
#include "CalculatorDisplay.h" #include "CalculatorDisplay.h"

View File

@ -88,7 +88,7 @@ task<String^> CopyPasteManager::GetStringToPaste(ViewMode mode, CategoryGroupTyp
// Retrieve the text in the clipboard // Retrieve the text in the clipboard
auto dataPackageView = Clipboard::GetContent(); auto dataPackageView = Clipboard::GetContent();
// TODO: Suport all formats supported by ClipboardHasText // TODO: Support all formats supported by ClipboardHasText
//-- add support to avoid pasting of expressions like 12 34(as of now we allow 1234) //-- add support to avoid pasting of expressions like 12 34(as of now we allow 1234)
//-- add support to allow pasting for expressions like .2 , -.2 //-- add support to allow pasting for expressions like .2 , -.2
//-- add support to allow pasting for expressions like 1.3e12(as of now we allow 1.3e+12) //-- add support to allow pasting for expressions like 1.3e12(as of now we allow 1.3e+12)

View File

@ -154,7 +154,7 @@ void DateCalculationEngine::GetDateDifference(_In_ DateTime date1, _In_ DateTime
if (tempDaysDiff < 0) if (tempDaysDiff < 0)
{ {
// pivotDate has gone over the end date; start from the begining of this unit // pivotDate has gone over the end date; start from the beginning of this unit
differenceInDates[unitIndex] -= 1; differenceInDates[unitIndex] -= 1;
pivotDate = tempPivotDate; pivotDate = tempPivotDate;
pivotDate = AdjustCalendarDate(pivotDate, dateUnit, static_cast<int>(differenceInDates[unitIndex])); pivotDate = AdjustCalendarDate(pivotDate, dateUnit, static_cast<int>(differenceInDates[unitIndex]));

View File

@ -32,7 +32,7 @@ namespace CalculatorApp
// Sometimes, like with popups, escape is treated as special and even // Sometimes, like with popups, escape is treated as special and even
// though it is handled we get it passed through to us. In those cases // though it is handled we get it passed through to us. In those cases
// we need to be able to ignore it (looking at e->Hanlded isn't sufficient // we need to be able to ignore it (looking at e->Handled isn't sufficient
// because that always returns true). // because that always returns true).
// The onlyOnce flag is used to indicate whether we should only ignore the // The onlyOnce flag is used to indicate whether we should only ignore the
// next escape, or keep ignoring until you explicitly HonorEscape. // next escape, or keep ignoring until you explicitly HonorEscape.

View File

@ -104,7 +104,7 @@ namespace CalculatorApp
TraceLogger(); TraceLogger();
// Any new Log method should // Any new Log method should
// a) decide the level of logging. This will help us in limiting recording of events only upto a certain level. See this link for guidance https://msdn.microsoft.com/en-us/library/windows/desktop/aa363742(v=vs.85).aspx // a) decide the level of logging. This will help us in limiting recording of events only up to a certain level. See this link for guidance https://msdn.microsoft.com/en-us/library/windows/desktop/aa363742(v=vs.85).aspx
// We're using Verbose level for events that are called frequently and needed only for debugging or capturing perf for specific scenarios // We're using Verbose level for events that are called frequently and needed only for debugging or capturing perf for specific scenarios
// b) should decide whether or not to log to telemetry and pass TraceLoggingKeyword(MICROSOFT_KEYWORD_TELEMETRY) accordingly // b) should decide whether or not to log to telemetry and pass TraceLoggingKeyword(MICROSOFT_KEYWORD_TELEMETRY) accordingly
// c) Should accept a variable number of additional data arguments if needed // c) Should accept a variable number of additional data arguments if needed

View File

@ -616,7 +616,7 @@ void StandardCalculatorViewModel::OnButtonPressed(Object^ parameter)
// Also, the Primary Display Value should not show in exponential format. // Also, the Primary Display Value should not show in exponential format.
// Hence the check below to ensure parity with Desktop Calculator. // Hence the check below to ensure parity with Desktop Calculator.
// Clear the FE mode if the switching to StandardMode, since 'C'/'CE' in StandardMode // Clear the FE mode if the switching to StandardMode, since 'C'/'CE' in StandardMode
// doesn't honour the FE button. // doesn't honor the FE button.
if (IsFToEChecked) if (IsFToEChecked)
{ {
IsFToEChecked = false; IsFToEChecked = false;

View File

@ -74,7 +74,7 @@ namespace CalculatorApp
Platform::String^ get() { return ref new Platform::String(m_original.abbreviation.c_str()); } Platform::String^ get() { return ref new Platform::String(m_original.abbreviation.c_str()); }
} }
// This method is used to return the desired autonamtion name for default unit in UnitConveter combo box. // This method is used to return the desired automation name for default unit in UnitConveter combo box.
Platform::String^ ToString() override Platform::String^ ToString() override
{ {
return AccessibleName; return AccessibleName;

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
#pragma once #pragma once
@ -29,7 +29,7 @@ namespace CalculatorApp
AppLifecycleLogger(); AppLifecycleLogger();
// Any new Log method should // Any new Log method should
// a) decide the level of logging. This will help us in limiting recording of events only upto a certain level. See this link for guidance https://msdn.microsoft.com/en-us/library/windows/desktop/aa363742(v=vs.85).aspx // a) decide the level of logging. This will help us in limiting recording of events only up to a certain level. See this link for guidance https://msdn.microsoft.com/en-us/library/windows/desktop/aa363742(v=vs.85).aspx
// We're using Verbose level for events that are called frequently and needed only for debugging or capturing perf for specific scenarios // We're using Verbose level for events that are called frequently and needed only for debugging or capturing perf for specific scenarios
// b) should decide whether or not to log to telemetry and pass TraceLoggingKeyword(MICROSOFT_KEYWORD_TELEMETRY) accordingly // b) should decide whether or not to log to telemetry and pass TraceLoggingKeyword(MICROSOFT_KEYWORD_TELEMETRY) accordingly
// c) Should accept a variable number of additional data arguments if needed // c) Should accept a variable number of additional data arguments if needed

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
#include "pch.h" #include "pch.h"
@ -154,7 +154,7 @@ void CalculationResult::OnIsInErrorPropertyChanged(bool /*oldValue*/, bool newVa
if (newValue) if (newValue)
{ {
// If there's an error message we need to override the normal display font // If there's an error message we need to override the normal display font
// with the font appropiate for this language. This is because the error // with the font appropriate for this language. This is because the error
// message is localized and therefore can contain characters that are not // message is localized and therefore can contain characters that are not
// available in the normal font. // available in the normal font.
// We use UIText as the font type because this is the most common font type to use // We use UIText as the font type because this is the most common font type to use

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
#include "pch.h" #include "pch.h"
@ -201,7 +201,7 @@ void OverflowTextBlock::UnregisterEventHandlers()
auto borderContainer = safe_cast<Border^>(GetTemplateChild("expressionborder")); auto borderContainer = safe_cast<Border^>(GetTemplateChild("expressionborder"));
// Adding an extra check, incase the returned template is null // Adding an extra check, in case the returned template is null
if (borderContainer != nullptr) if (borderContainer != nullptr)
{ {
borderContainer->PointerEntered -= m_pointerEnteredEventToken; borderContainer->PointerEntered -= m_pointerEnteredEventToken;

View File

@ -166,7 +166,7 @@ void CalculatorProgrammerBitFlipPanel::OnBitToggled(_In_ Object^ sender, _In_ Ro
// Any input from the Numpad may also result in toggling the bit as their state is bound to the BinaryDisplayValue. // Any input from the Numpad may also result in toggling the bit as their state is bound to the BinaryDisplayValue.
// Also, if the mode is switched to other Calculator modes when the BitFlip panel is open, // Also, if the mode is switched to other Calculator modes when the BitFlip panel is open,
// a race condition exists in which the IsProgrammerMode property is still true and the UpdatePrimaryResult() is called, // a race condition exists in which the IsProgrammerMode property is still true and the UpdatePrimaryResult() is called,
// which continously alters the Display Value and the state of the Bit Flip buttons. // which continuously alters the Display Value and the state of the Bit Flip buttons.
if ((Model->IsBitFlipChecked) if ((Model->IsBitFlipChecked)
&& Model->IsProgrammer) && Model->IsProgrammer)
{ {

View File

@ -116,7 +116,7 @@ void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
void MainPage::WindowSizeChanged(_In_ Platform::Object^ /*sender*/, _In_ Windows::UI::Core::WindowSizeChangedEventArgs^ e) void MainPage::WindowSizeChanged(_In_ Platform::Object^ /*sender*/, _In_ Windows::UI::Core::WindowSizeChangedEventArgs^ e)
{ {
// We dont use layout aware page's view states, we have our own // We don't use layout aware page's view states, we have our own
UpdateViewState(); UpdateViewState();
} }
@ -321,7 +321,7 @@ void MainPage::EnsureCalculator()
CalcHolder->Child = m_calculator; CalcHolder->Child = m_calculator;
// Calculator's "default" state is visibile, but if we get delay loaded // Calculator's "default" state is visible, but if we get delay loaded
// when in converter, we should not be visible. This is not a problem for converter // when in converter, we should not be visible. This is not a problem for converter
// since it's default state is hidden. // since it's default state is hidden.
ShowHideControls(this->Model->Mode); ShowHideControls(this->Model->Mode);

View File

@ -48,7 +48,7 @@ void Memory::MemoryListItemClick(_In_ Object^ sender, _In_ ItemClickEventArgs^ e
{ {
MemoryItemViewModel^ memorySlot = safe_cast<MemoryItemViewModel^>(e->ClickedItem); MemoryItemViewModel^ memorySlot = safe_cast<MemoryItemViewModel^>(e->ClickedItem);
// Incase the memory list is clicked and enter is pressed, // In case the memory list is clicked and enter is pressed,
// On Item clicked event gets fired and e->ClickedItem is Null. // On Item clicked event gets fired and e->ClickedItem is Null.
if (memorySlot != nullptr) if (memorySlot != nullptr)
{ {

View File

@ -102,7 +102,7 @@
<!-- <!--
This is the only button in all of the app that should ever have a explicit reference to KeyboardShortcutManager in Xaml This is the only button in all of the app that should ever have a explicit reference to KeyboardShortcutManager in Xaml
this is needed because we need to have at least 1 refernece from Xaml so the right metadata is generated for the this is needed because we need to have at least 1 reference from Xaml so the right metadata is generated for the
KeyboardShortcutManager class, otherwise the Xaml will stop parsing and the app won't boot therefore: KeyboardShortcutManager class, otherwise the Xaml will stop parsing and the app won't boot therefore:
DO NOT REMOVE the common:KeyboardShortcutManager.Character from this element, it's value will be overwritten by the DO NOT REMOVE the common:KeyboardShortcutManager.Character from this element, it's value will be overwritten by the
string coming from the RESW file string coming from the RESW file

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
// //
@ -72,7 +72,7 @@ SupplementaryResults::SupplementaryResults() :
void SupplementaryResults::RefreshData() void SupplementaryResults::RefreshData()
{ {
// Copy the list so that when we chop stuff off, we dont modify the original // Copy the list so that when we chop stuff off, we don't modify the original
// complete list. // complete list.
m_data->Clear(); m_data->Clear();
for(SupplementaryResult^ sr : safe_cast<UnitConverterViewModel^>(this->DataContext)->SupplementaryResults) for(SupplementaryResult^ sr : safe_cast<UnitConverterViewModel^>(this->DataContext)->SupplementaryResults)

View File

@ -109,7 +109,7 @@ namespace CalculatorApp
that->InvokeWindowClosingHandlers(); that->InvokeWindowClosingHandlers();
// This is to ensure InvokeWindowClosingHandlers is be done before RemoveWindowFromMap // This is to ensure InvokeWindowClosingHandlers is be done before RemoveWindowFromMap
// If InvokeWindowClosingHandlers throws any exception we want it to crash the application // If InvokeWindowClosingHandlers throws any exception we want it to crash the application
// so we are ok not setting closingHandlersCompletedEvent in that case // so we are OK not setting closingHandlersCompletedEvent in that case
closingHandlersCompletedEvent.set(); closingHandlersCompletedEvent.set();
that->m_coreDispatcher->StopProcessEvents(); that->m_coreDispatcher->StopProcessEvents();
Window::Current->Close(); Window::Current->Close();

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved. // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. // Licensed under the MIT License.
#include "pch.h" #include "pch.h"
@ -83,7 +83,7 @@ namespace CalculatorUnitTests
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(0, 10, false, L"999", 64, 32), L"Verify TryAddDigit succeeds."); VERIFY_IS_TRUE(m_calcInput.TryAddDigit(0, 10, false, L"999", 64, 32), L"Verify TryAddDigit succeeds.");
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(0, 10, false, L"999", 64, 32), L"Verify TryAddDigit succeeds."); VERIFY_IS_TRUE(m_calcInput.TryAddDigit(0, 10, false, L"999", 64, 32), L"Verify TryAddDigit succeeds.");
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(0, 10, false, L"999", 64, 32), L"Verify TryAddDigit succeeds."); VERIFY_IS_TRUE(m_calcInput.TryAddDigit(0, 10, false, L"999", 64, 32), L"Verify TryAddDigit succeeds.");
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10, false), L"Verify leading zeroes are ignored."); VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10, false), L"Verify leading zeros are ignored.");
} }
TEST_METHOD(TryAddDigitMaxCount) TEST_METHOD(TryAddDigitMaxCount)
{ {