Fix shift overflow bug in ++ and -- (#85)

pull/86/head
Pharap 4 years ago committed by GitHub
parent 892df22ee8
commit d8c2300585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/FixedPoints/SFixedMemberFunctions.h
  2. 4
      src/FixedPoints/UFixedMemberFunctions.h

@ -221,14 +221,14 @@ constexpr SFixed<Integer, Fraction> SFixed<Integer, Fraction>::operator -() cons
template< unsigned Integer, unsigned Fraction >
SFixed<Integer, Fraction> & SFixed<Integer, Fraction>::operator ++()
{
this->value += (1 << FractionSize);
this->value += (static_cast<InternalType>(1) << FractionSize);
return *this;
}
template< unsigned Integer, unsigned Fraction >
SFixed<Integer, Fraction> & SFixed<Integer, Fraction>::operator --()
{
this->value -= (1 << FractionSize);
this->value -= (static_cast<InternalType>(1) << FractionSize);
return *this;
}

@ -206,14 +206,14 @@ constexpr UFixed<Integer, Fraction> UFixed<Integer, Fraction>::fromInternal(cons
template< unsigned Integer, unsigned Fraction >
UFixed<Integer, Fraction> & UFixed<Integer, Fraction>::operator ++()
{
this->value += (1 << FractionSize);
this->value += (static_cast<InternalType>(1) << FractionSize);
return *this;
}
template< unsigned Integer, unsigned Fraction >
UFixed<Integer, Fraction> & UFixed<Integer, Fraction>::operator --()
{
this->value -= (1 << FractionSize);
this->value -= (static_cast<InternalType>(1) << FractionSize);
return *this;
}

Loading…
Cancel
Save