mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix GncInt128 shift operators when shift amount will clear a leg.
This commit is contained in:
parent
4a134ae0b1
commit
570c8a8d60
@ -309,12 +309,18 @@ GncInt128::operator<<= (unsigned int i) noexcept
|
||||
m_lo = 0;
|
||||
return *this;
|
||||
}
|
||||
if (i < legbits)
|
||||
{
|
||||
uint64_t carry {(m_lo & (((UINT64_C(1) << i) - 1) << (legbits - i)))};
|
||||
m_lo <<= i;
|
||||
m_hi <<= i;
|
||||
m_hi += carry;
|
||||
return *this;
|
||||
}
|
||||
m_hi = m_lo << (i - legbits);
|
||||
m_lo = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
GncInt128&
|
||||
GncInt128::operator>>= (unsigned int i) noexcept
|
||||
@ -326,12 +332,18 @@ GncInt128::operator>>= (unsigned int i) noexcept
|
||||
m_lo = 0;
|
||||
return *this;
|
||||
}
|
||||
if (i < legbits)
|
||||
{
|
||||
uint64_t carry {(m_hi & ((UINT64_C(1) << i) - 1))};
|
||||
m_lo >>= i;
|
||||
m_hi >>= i;
|
||||
m_lo += (carry << (legbits - i));
|
||||
return *this;
|
||||
}
|
||||
m_lo = m_hi >> (i - legbits);
|
||||
m_hi = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
GncInt128&
|
||||
GncInt128::operator-= (const GncInt128& b) noexcept
|
||||
|
Loading…
Reference in New Issue
Block a user