mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix GncInt128 maxbits to account for the flag bits.
This commit is contained in:
parent
de1c56b53d
commit
a467d0d397
@ -501,7 +501,12 @@ GncInt128::operator*= (const GncInt128& b) noexcept
|
||||
}
|
||||
|
||||
unsigned int abits {bits()}, bbits {b.bits()};
|
||||
if (abits + bbits > maxbits)
|
||||
/* If the product of the high bytes < 7fff then the result will have abits +
|
||||
* bbits -1 bits and won't actually overflow. It's not worth the effort to
|
||||
* work that out for this corner-case, so we'll take the risk and calculate
|
||||
* the product and catch the overflow later.
|
||||
*/
|
||||
if (abits + bbits - 1 > maxbits)
|
||||
{
|
||||
flags |= overflow;
|
||||
m_hi = set_flags(m_hi, flags);
|
||||
|
@ -67,9 +67,10 @@ class GncInt128
|
||||
uint64_t m_lo;
|
||||
|
||||
public:
|
||||
static const unsigned int flagbits = 3;
|
||||
static const unsigned int numlegs = 2;
|
||||
static const unsigned int legbits = 64;
|
||||
static const unsigned int maxbits = legbits * numlegs;
|
||||
static const unsigned int maxbits = legbits * numlegs - flagbits;
|
||||
|
||||
enum // Values for m_flags
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user