diff --git a/src/CalcManager/CEngine/scioper.cpp b/src/CalcManager/CEngine/scioper.cpp index 80cfe3b2..9ced7021 100644 --- a/src/CalcManager/CEngine/scioper.cpp +++ b/src/CalcManager/CEngine/scioper.cpp @@ -78,7 +78,7 @@ CalcEngine::Rational CCalcEngine::DoOperation(int operation, CalcEngine::Rationa case IDC_DIV: case IDC_MOD: { - int iNumeratorSign = 1, iDenominatorSign = 1, iFinalSign = 1; + int iNumeratorSign = 1, iDenominatorSign = 1; auto temp = result; result = rhs; @@ -107,30 +107,30 @@ CalcEngine::Rational CCalcEngine::DoOperation(int operation, CalcEngine::Rationa if (operation == IDC_DIV) { - iFinalSign = iNumeratorSign * iDenominatorSign; result /= temp; + if (m_fIntegerMode && (iNumeratorSign * iDenominatorSign) == -1) + { + result = -(Integer(result)); + } } else { if (m_fIntegerMode) { // Programmer mode, use remrat (remainder after division) - iFinalSign = iNumeratorSign; result %= temp; + + if (iNumeratorSign == -1) + { + result = -(Integer(result)); + } } else { //other modes, use modrat (modulus after division) - iFinalSign = iDenominatorSign; result = Mod(result, temp); } } - - if (m_fIntegerMode && iFinalSign == -1) - { - result = -(Integer(result)); - } - break; }