mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add increment, decrement, and shift-eauals operators to QofInt128.
They'll be needed for division.
This commit is contained in:
parent
c7752d5d3c
commit
1c83db5896
@ -172,6 +172,30 @@ QofInt128::operator bool() const noexcept
|
||||
return ! isZero ();
|
||||
}
|
||||
|
||||
QofInt128&
|
||||
QofInt128::operator++ () noexcept
|
||||
{
|
||||
return operator+=(UINT64_C(1));
|
||||
}
|
||||
|
||||
QofInt128&
|
||||
QofInt128::operator++ (int) noexcept
|
||||
{
|
||||
return operator+=(UINT64_C(1));
|
||||
}
|
||||
|
||||
QofInt128&
|
||||
QofInt128::operator-- () noexcept
|
||||
{
|
||||
return operator-=(UINT64_C(1));
|
||||
}
|
||||
|
||||
QofInt128&
|
||||
QofInt128::operator-- (int) noexcept
|
||||
{
|
||||
return operator-=(UINT64_C(1));
|
||||
}
|
||||
|
||||
QofInt128&
|
||||
QofInt128::operator+= (const QofInt128& b) noexcept
|
||||
{
|
||||
@ -187,6 +211,39 @@ QofInt128::operator+= (const QofInt128& b) noexcept
|
||||
return *this;
|
||||
}
|
||||
|
||||
QofInt128&
|
||||
QofInt128::operator<<= (uint i) noexcept
|
||||
{
|
||||
if (i > maxbits)
|
||||
{
|
||||
m_flags &= 0xfe;
|
||||
m_hi = 0;
|
||||
m_lo = 0;
|
||||
return *this;
|
||||
}
|
||||
uint64_t carry {(m_lo & (((1 << i) - 1) << (legbits - i)))};
|
||||
m_lo <<= i;
|
||||
m_hi <<= i;
|
||||
m_hi += carry;
|
||||
return *this;
|
||||
}
|
||||
|
||||
QofInt128&
|
||||
QofInt128::operator>>= (uint i) noexcept
|
||||
{
|
||||
if (i > maxbits)
|
||||
{
|
||||
m_flags &= 0xfe;
|
||||
m_hi = 0;
|
||||
m_lo = 0;
|
||||
return *this;
|
||||
}
|
||||
uint64_t carry {(m_hi & ((1 << i) - 1))};
|
||||
m_lo >>= i;
|
||||
m_hi >>= i;
|
||||
m_lo += (carry << (legbits - i));
|
||||
return *this;
|
||||
}
|
||||
|
||||
QofInt128&
|
||||
QofInt128::operator-= (const QofInt128& b) noexcept
|
||||
|
@ -168,7 +168,11 @@ enum // Values for m_flags
|
||||
explicit operator bool() const noexcept;
|
||||
|
||||
QofInt128& operator++ () noexcept;
|
||||
QofInt128 operator++ (int) noexcept;
|
||||
QofInt128& operator++ (int) noexcept;
|
||||
QofInt128& operator-- () noexcept;
|
||||
QofInt128& operator-- (int) noexcept;
|
||||
QofInt128& operator<<= (uint i) noexcept;
|
||||
QofInt128& operator>>= (uint i) noexcept;
|
||||
QofInt128& operator+= (const QofInt128& b) noexcept;
|
||||
QofInt128& operator-= (const QofInt128& b) noexcept;
|
||||
QofInt128& operator*= (const QofInt128& b) noexcept;
|
||||
|
Loading…
Reference in New Issue
Block a user