From 784482387dd90065db45bb116d5d4d0e3030458c Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Wed, 4 Apr 2018 07:47:49 +0100 Subject: [PATCH] Fix bug in roundFixed The bug was due to part of the former code being left in by mistake. --- src/FixedPoints/Utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FixedPoints/Utils.h b/src/FixedPoints/Utils.h index 14458f0..f039af0 100644 --- a/src/FixedPoints/Utils.h +++ b/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 >