Fix bug in roundFixed (#32)

The bug was due to part of the former code being left in by mistake.
pull/33/head
Pharap 7 years ago committed by GitHub
parent c3994a06d5
commit e5ac682a12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/FixedPoints/Utils.h

@ -127,7 +127,7 @@ template< unsigned Integer, unsigned Fraction >
constexpr UFixed<Integer, Fraction> roundFixed(const UFixed<Integer, Fraction> & value)
{
using OutputType = UFixed<Integer, Fraction>;
return ((value.getFraction() >= OutputType(0.5).getFraction()) != 0) ? ceilFixed(value) : floorFixed(value);
return (value.getFraction() >= OutputType(0.5).getFraction()) ? ceilFixed(value) : floorFixed(value);
}
template< unsigned Integer, unsigned Fraction >
@ -136,8 +136,8 @@ constexpr SFixed<Integer, Fraction> roundFixed(const SFixed<Integer, Fraction> &
using OutputType = SFixed<Integer, Fraction>;
return
signbitFixed(value)
? ((value.getFraction() <= OutputType(0.5).getFraction()) != 0) ? floorFixed(value) : ceilFixed(value)
: ((value.getFraction() >= OutputType(0.5).getFraction()) != 0) ? ceilFixed(value) : floorFixed(value);
? (value.getFraction() <= OutputType(0.5).getFraction()) ? floorFixed(value) : ceilFixed(value)
: (value.getFraction() >= OutputType(0.5).getFraction()) ? ceilFixed(value) : floorFixed(value);
}
template< unsigned Integer, unsigned Fraction >

Loading…
Cancel
Save