mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-21 22:03:11 -07:00
Replace unnecessary Rational::Not with Xor operation
This commit is contained in:
parent
41db5fa28d
commit
dde5f59dc2
6 changed files with 5 additions and 12 deletions
|
@ -379,11 +379,6 @@ namespace CalcEngine
|
|||
return lhs;
|
||||
}
|
||||
|
||||
Rational Rational::Not(Rational const& chopNum) const
|
||||
{
|
||||
return *this ^ chopNum;
|
||||
}
|
||||
|
||||
bool Rational::IsZero() const
|
||||
{
|
||||
return this->P().IsZero();
|
||||
|
|
|
@ -1053,7 +1053,7 @@ wstring CCalcEngine::GetStringForDisplay(Rational const& rat, uint32_t radix)
|
|||
if ((radix == 10) && fMsb)
|
||||
{
|
||||
// If high bit is set, then get the decimal number in negative 2's compl form.
|
||||
tempRat = -(tempRat.Not(m_chopNumbers[m_numwidth]) + 1);
|
||||
tempRat = -((tempRat ^ m_chopNumbers[m_numwidth]) + 1);
|
||||
}
|
||||
|
||||
result = tempRat.ToString(radix, m_nFE, m_precision);
|
||||
|
|
|
@ -65,7 +65,7 @@ CalcEngine::Rational CCalcEngine::TruncateNumForIntMath(CalcEngine::Rational con
|
|||
{
|
||||
// if negative make positive by doing a twos complement
|
||||
result = -(result) - 1;
|
||||
result = result.Not(m_chopNumbers[m_numwidth]);
|
||||
result ^= m_chopNumbers[m_numwidth];
|
||||
}
|
||||
|
||||
result &= m_chopNumbers[m_numwidth];
|
||||
|
|
|
@ -89,7 +89,7 @@ CalcEngine::Rational CCalcEngine::DoOperation(int operation, CalcEngine::Rationa
|
|||
|
||||
if (fMsb)
|
||||
{
|
||||
result = rhs.Not(m_chopNumbers[m_numwidth]) + 1;
|
||||
result = (rhs ^ m_chopNumbers[m_numwidth]) + 1;
|
||||
|
||||
iNumeratorSign = -1;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ CalcEngine::Rational CCalcEngine::DoOperation(int operation, CalcEngine::Rationa
|
|||
|
||||
if (fMsb)
|
||||
{
|
||||
temp = temp.Not(m_chopNumbers[m_numwidth]) + 1;
|
||||
temp = (temp ^ m_chopNumbers[m_numwidth]) + 1;
|
||||
|
||||
iDenominatorSign = -1;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RADIX_TYPE radixtype, NUM_WIDTH numwid
|
|||
if (fMsb)
|
||||
{
|
||||
// If high bit is set, then get the decimal number in -ve 2'scompl form.
|
||||
auto tempResult = m_currentVal.Not(m_chopNumbers[m_numwidth]);
|
||||
auto tempResult = m_currentVal ^ m_chopNumbers[m_numwidth];
|
||||
|
||||
m_currentVal = -(tempResult + 1);
|
||||
}
|
||||
|
|
|
@ -56,8 +56,6 @@ namespace CalcEngine
|
|||
friend Rational operator|(Rational lhs, Rational const& rhs);
|
||||
friend Rational operator^(Rational lhs, Rational const& rhs);
|
||||
|
||||
Rational Not(Rational const& chopNum) const;
|
||||
|
||||
bool IsZero() const;
|
||||
|
||||
friend bool operator==(Rational const& lhs, Rational const& rhs);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue