mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-21 22:03:11 -07:00
Remove unnecessary Rational::IsZero() in favor of == 0 comparisons
This commit is contained in:
parent
75792d4a6d
commit
14d8dc964f
4 changed files with 4 additions and 13 deletions
|
@ -444,11 +444,6 @@ namespace CalcEngine
|
|||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
bool Rational::IsZero() const
|
||||
{
|
||||
return this->P().IsZero();
|
||||
}
|
||||
|
||||
wstring Rational::ToString(uint32_t radix, NUMOBJ_FMT fmt, int32_t precision) const
|
||||
{
|
||||
PRAT rat = this->ToPRAT();
|
||||
|
|
|
@ -11,7 +11,7 @@ using namespace CalcEngine::RationalMath;
|
|||
CalcEngine::Rational CCalcEngine::DoOperation(int operation, CalcEngine::Rational const& lhs, CalcEngine::Rational const& rhs)
|
||||
{
|
||||
// Remove any variance in how 0 could be represented in rat e.g. -0, 0/n, etc.
|
||||
auto result = (!lhs.IsZero() ? lhs : 0);
|
||||
auto result = (lhs != 0 ? lhs : 0);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -85,12 +85,9 @@ bool CCalcEngine::TryToggleBit(CalcEngine::Rational& rat, DWORD wbitno)
|
|||
}
|
||||
|
||||
Rational result = Integer(rat);
|
||||
if (result.IsZero())
|
||||
{
|
||||
// This is the same work around happenning in SciCalcFunctions. Ought to move to intrat function itself.
|
||||
// Basic bug is there which doesn't treat 0/ n as 0, or -0 as 0 etc.
|
||||
result = 0;
|
||||
}
|
||||
|
||||
// Remove any variance in how 0 could be represented in rat e.g. -0, 0/n, etc.
|
||||
result = (result != 0 ? result : 0);
|
||||
|
||||
// XOR the result with 2^wbitno power
|
||||
rat = result ^ Pow(2, static_cast<int32_t>(wbitno));
|
||||
|
|
|
@ -63,7 +63,6 @@ namespace CalcEngine
|
|||
friend bool operator<=(Rational const& lhs, Rational const& rhs);
|
||||
friend bool operator>=(Rational const& lhs, Rational const& rhs);
|
||||
|
||||
bool IsZero() const;
|
||||
std::wstring ToString(uint32_t radix, NUMOBJ_FMT format, int32_t precision) const;
|
||||
uint64_t ToUInt64_t() const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue