From e5ac682a12b58db13991482e8babbdd4a4882c37 Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Wed, 4 Apr 2018 07:51:32 +0100 Subject: [PATCH] Fix bug in roundFixed (#32) 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 roundFixed(const UFixed & value) { using OutputType = UFixed; - 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 roundFixed(const SFixed & using OutputType = SFixed; 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 >