From d2a63faf53f3545085bfad0ed78c7e700e0b9a61 Mon Sep 17 00:00:00 2001 From: Pharap Date: Tue, 3 Oct 2017 14:40:53 +0100 Subject: [PATCH] Eradicate Warnings --- src/FixedPoints/Details.h | 25 +++++++++++++------------ src/FixedPoints/SFixedMemberFunctions.h | 15 +++------------ src/FixedPoints/UFixedMemberFunctions.h | 1 - src/FixedPoints/Utils.h | 4 ++-- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/FixedPoints/Details.h b/src/FixedPoints/Details.h index 6574ca4..ee59c92 100644 --- a/src/FixedPoints/Details.h +++ b/src/FixedPoints/Details.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -203,17 +204,17 @@ namespace FIXED_POINTS_DETAILS static inline int64_t Random() { return (static_cast(random()) << 32) | static_cast(random()); } }; - // Here be dragons!! - // - // - // - // /\___/\ ~ - // ( O . O ) \\ - // > ^ < // - // ( \ / )// - // u U U u - // - // Or cats? - // ~Mwrow~ + /////////////////////// + // Here be dragons!! // + // // + // /\___/\ _ // + // ( O . O ) \\ // + // > ^ < // // + // ( \ / )// // + // u U U u // + // // + // Or cats?... // + // ~Mwrow~ // + /////////////////////// } FIXED_POINTS_END_NAMESPACE \ No newline at end of file diff --git a/src/FixedPoints/SFixedMemberFunctions.h b/src/FixedPoints/SFixedMemberFunctions.h index cbaf1d5..e3b817c 100644 --- a/src/FixedPoints/SFixedMemberFunctions.h +++ b/src/FixedPoints/SFixedMemberFunctions.h @@ -35,7 +35,7 @@ constexpr typename SFixed::InternalType SFixed constexpr typename SFixed::IntegerType SFixed::getInteger(void) const { - return static_cast(this->value >> IntegerShift) & IntegerMask | ((this->value < 0) ? ~IntegerMask : 0); + return (static_cast(this->value >> IntegerShift) & IntegerMask) | ((this->value < 0) ? ~IntegerMask : 0); } template< unsigned Integer, unsigned Fraction > @@ -57,10 +57,6 @@ constexpr SFixed::operator IntegerType(void) const template< unsigned Integer, unsigned Fraction > constexpr SFixed::operator float(void) const { - /*return (1.0f / Scale) * - (this->value < 0) ? - -((-this->value) & IdentityMask) : - this->value & IdentityMask; */ return (1.0f / Scale) * static_cast ((this->value & IdentityMask) | @@ -70,10 +66,6 @@ constexpr SFixed::operator float(void) const template< unsigned Integer, unsigned Fraction > constexpr SFixed::operator double(void) const { - /*return (1.0 / Scale) * - (this->value < 0) ? - -((-this->value) & IdentityMask) : - this->value & IdentityMask; */ return (1.0 / Scale) * static_cast ((this->value & IdentityMask) | @@ -84,12 +76,11 @@ template< unsigned Integer, unsigned Fraction > template< unsigned IntegerOut, unsigned FractionOut > constexpr SFixed::operator SFixed(void) const { - using OutputType = UFixed; + using OutputType = SFixed; using OutputInternalType = typename OutputType::InternalType; using OutputShiftType = typename OutputType::ShiftType; - using InputType = UFixed; - using InputInternalType = typename InputType::InternalType; + using InputType = SFixed; using InputShiftType = typename InputType::ShiftType; return diff --git a/src/FixedPoints/UFixedMemberFunctions.h b/src/FixedPoints/UFixedMemberFunctions.h index 4d43b70..3e79aad 100644 --- a/src/FixedPoints/UFixedMemberFunctions.h +++ b/src/FixedPoints/UFixedMemberFunctions.h @@ -75,7 +75,6 @@ constexpr UFixed::operator UFixed(vo using OutputShiftType = typename OutputType::ShiftType; using InputType = UFixed; - using InputInternalType = typename InputType::InternalType; using InputShiftType = typename InputType::ShiftType; return diff --git a/src/FixedPoints/Utils.h b/src/FixedPoints/Utils.h index 49bdecf..4c07250 100644 --- a/src/FixedPoints/Utils.h +++ b/src/FixedPoints/Utils.h @@ -116,8 +116,8 @@ constexpr SFixed roundFixed(const SFixed & return ( ((value.getInternal() & OutputType::MidpointMask) != 0) && - !signbitFixed(value) || - ((value.getInternal() & OutputType::LesserMidpointMask) != 0) + (!signbitFixed(value) || + ((value.getInternal() & OutputType::LesserMidpointMask) != 0)) ) ? ceilFixed(value) : floorFixed(value);