mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
Update scicomm.cpp
Added functionality so that you can input log and then type value in which you would like to take the log of.
This commit is contained in:
parent
2f05e07d41
commit
1d96e6d84f
1 changed files with 46 additions and 7 deletions
|
@ -300,10 +300,10 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
|||
/* In that case we better use the number before the operator */
|
||||
/* was entered, otherwise, things like 5+ 1/x give Divide By */
|
||||
/* zero. This way 5+=gives 10 like most calculators do. */
|
||||
if (IsBinOpCode(m_nLastCom))
|
||||
/* if (IsBinOpCode(m_nLastCom))
|
||||
{
|
||||
m_currentVal = m_lastVal;
|
||||
}
|
||||
}*/
|
||||
|
||||
// we do not add percent sign to history or to two line display.
|
||||
// instead, we add the result of applying %.
|
||||
|
@ -328,7 +328,25 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (wParam == IDC_LOG)
|
||||
{
|
||||
|
||||
m_currentVal = 0;
|
||||
extraVariable = 2;
|
||||
|
||||
ProcessCommand(IDC_OPENP);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_currentVal = SciCalcFunctions(m_currentVal, (uint32_t)wParam);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_bError)
|
||||
return;
|
||||
|
@ -348,7 +366,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
|||
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)))
|
||||
|| (wParam == IDC_COT) || (wParam == IDC_SECH) || (wParam == IDC_CSCH) || (wParam == IDC_COTH)) || (wParam == IDC_LOG)) //Added log here
|
||||
{
|
||||
m_bInv = false;
|
||||
}
|
||||
|
@ -501,10 +519,13 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
|||
case IDC_OPENP:
|
||||
case IDC_CLOSEP:
|
||||
|
||||
|
||||
// -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 precedence holding array is full
|
||||
ClearDisplay();
|
||||
|
||||
if ((m_openParenCount >= MAXPRECDEPTH && (wParam == IDC_OPENP)) || (!m_openParenCount && (wParam != IDC_OPENP))
|
||||
|| ((m_precedenceOpCount >= MAXPRECDEPTH && m_nPrecOp[m_precedenceOpCount - 1] != 0)))
|
||||
{
|
||||
|
@ -519,10 +540,13 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
|||
|
||||
if (wParam == IDC_OPENP)
|
||||
{
|
||||
|
||||
// if there's an omitted multiplication sign
|
||||
if (IsDigitOpCode(m_nLastCom) || IsUnaryOpCode(m_nLastCom) || m_nLastCom == IDC_PNT || m_nLastCom == IDC_CLOSEP)
|
||||
{
|
||||
|
||||
ProcessCommand(IDC_MUL);
|
||||
|
||||
}
|
||||
|
||||
CheckAndAddLastBinOpToHistory();
|
||||
|
@ -549,10 +573,22 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
|||
m_nTempCom = 0;
|
||||
m_nOpCode = 0;
|
||||
m_bChangeOp = false; // a ( is like starting a fresh sub equation
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Last thing keyed in was an operator. Lets do the op on a duplicate of the last entry.
|
||||
if (extraVariable == 2)
|
||||
{
|
||||
wParam = IDC_LOG;
|
||||
m_currentVal = SciCalcFunctions(m_currentVal, (uint32_t)wParam);
|
||||
extraVariable = 0;
|
||||
wParam = IDC_CLOSEP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (IsBinOpCode(m_nLastCom))
|
||||
{
|
||||
m_currentVal = m_lastVal;
|
||||
|
@ -603,9 +639,12 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
|||
m_pCalcDisplay->SetParenthesisNumber(static_cast<unsigned int>(m_openParenCount));
|
||||
}
|
||||
|
||||
|
||||
if (!m_bError)
|
||||
{
|
||||
|
||||
DisplayNum();
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue