Skip to content

Commit e5ac682

Browse files
authored
Fix bug in roundFixed (#32)
The bug was due to part of the former code being left in by mistake.
1 parent c3994a0 commit e5ac682

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/FixedPoints/Utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ template< unsigned Integer, unsigned Fraction >
127127
constexpr UFixed<Integer, Fraction> roundFixed(const UFixed<Integer, Fraction> & value)
128128
{
129129
using OutputType = UFixed<Integer, Fraction>;
130-
return ((value.getFraction() >= OutputType(0.5).getFraction()) != 0) ? ceilFixed(value) : floorFixed(value);
130+
return (value.getFraction() >= OutputType(0.5).getFraction()) ? ceilFixed(value) : floorFixed(value);
131131
}
132132

133133
template< unsigned Integer, unsigned Fraction >
@@ -136,8 +136,8 @@ constexpr SFixed<Integer, Fraction> roundFixed(const SFixed<Integer, Fraction> &
136136
using OutputType = SFixed<Integer, Fraction>;
137137
return
138138
signbitFixed(value)
139-
? ((value.getFraction() <= OutputType(0.5).getFraction()) != 0) ? floorFixed(value) : ceilFixed(value)
140-
: ((value.getFraction() >= OutputType(0.5).getFraction()) != 0) ? ceilFixed(value) : floorFixed(value);
139+
? (value.getFraction() <= OutputType(0.5).getFraction()) ? floorFixed(value) : ceilFixed(value)
140+
: (value.getFraction() >= OutputType(0.5).getFraction()) ? ceilFixed(value) : floorFixed(value);
141141
}
142142

143143
template< unsigned Integer, unsigned Fraction >

0 commit comments

Comments
 (0)