From edcfdea949d0c73ee86738f3211a59baaf722101 Mon Sep 17 00:00:00 2001 From: maruncz Date: Wed, 21 Apr 2021 15:08:15 +0200 Subject: [PATCH] fixed some warnings --- libfixmath/fix16.hpp | 70 +++++++++++++++++++++--------------------- libfixmath/fix16_exp.c | 3 +- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/libfixmath/fix16.hpp b/libfixmath/fix16.hpp index dc8a5b7..95f6f9a 100644 --- a/libfixmath/fix16.hpp +++ b/libfixmath/fix16.hpp @@ -8,11 +8,11 @@ class Fix16 { fix16_t value; Fix16() { value = 0; } - Fix16(const Fix16 &inValue) { value = inValue.value; } - Fix16(const fix16_t inValue) { value = inValue; } - Fix16(const float inValue) { value = fix16_from_float(inValue); } - Fix16(const double inValue) { value = fix16_from_dbl(inValue); } - Fix16(const int16_t inValue) { value = fix16_from_int(inValue); } + Fix16(const Fix16 &inValue) { value = inValue.value; } + Fix16(const fix16_t inValue) { value = inValue; } + Fix16(const float inValue) { value = fix16_from_float(inValue); } + Fix16(const double inValue) { value = fix16_from_dbl(inValue); } + Fix16(const int16_t inValue) { value = fix16_from_int(inValue); } operator fix16_t() const { return value; } operator double() const { return fix16_to_dbl(value); } @@ -105,41 +105,41 @@ class Fix16 { const Fix16 sdiv(const int16_t other) const { Fix16 ret = fix16_sdiv(value, fix16_from_int(other)); return ret; } #endif - const int operator==(const Fix16 &other) const { return (value == other.value); } - const int operator==(const fix16_t other) const { return (value == other); } - const int operator==(const double other) const { return (value == fix16_from_dbl(other)); } - const int operator==(const float other) const { return (value == fix16_from_float(other)); } - const int operator==(const int16_t other) const { return (value == fix16_from_int(other)); } + int operator==(const Fix16 &other) const { return (value == other.value); } + int operator==(const fix16_t other) const { return (value == other); } + int operator==(const double other) const { return (value == fix16_from_dbl(other)); } + int operator==(const float other) const { return (value == fix16_from_float(other)); } + int operator==(const int16_t other) const { return (value == fix16_from_int(other)); } - const int operator!=(const Fix16 &other) const { return (value != other.value); } - const int operator!=(const fix16_t other) const { return (value != other); } - const int operator!=(const double other) const { return (value != fix16_from_dbl(other)); } - const int operator!=(const float other) const { return (value != fix16_from_float(other)); } - const int operator!=(const int16_t other) const { return (value != fix16_from_int(other)); } + int operator!=(const Fix16 &other) const { return (value != other.value); } + int operator!=(const fix16_t other) const { return (value != other); } + int operator!=(const double other) const { return (value != fix16_from_dbl(other)); } + int operator!=(const float other) const { return (value != fix16_from_float(other)); } + int operator!=(const int16_t other) const { return (value != fix16_from_int(other)); } - const int operator<=(const Fix16 &other) const { return (value <= other.value); } - const int operator<=(const fix16_t other) const { return (value <= other); } - const int operator<=(const double other) const { return (value <= fix16_from_dbl(other)); } - const int operator<=(const float other) const { return (value <= fix16_from_float(other)); } - const int operator<=(const int16_t other) const { return (value <= fix16_from_int(other)); } + int operator<=(const Fix16 &other) const { return (value <= other.value); } + int operator<=(const fix16_t other) const { return (value <= other); } + int operator<=(const double other) const { return (value <= fix16_from_dbl(other)); } + int operator<=(const float other) const { return (value <= fix16_from_float(other)); } + int operator<=(const int16_t other) const { return (value <= fix16_from_int(other)); } - const int operator>=(const Fix16 &other) const { return (value >= other.value); } - const int operator>=(const fix16_t other) const { return (value >= other); } - const int operator>=(const double other) const { return (value >= fix16_from_dbl(other)); } - const int operator>=(const float other) const { return (value >= fix16_from_float(other)); } - const int operator>=(const int16_t other) const { return (value >= fix16_from_int(other)); } + int operator>=(const Fix16 &other) const { return (value >= other.value); } + int operator>=(const fix16_t other) const { return (value >= other); } + int operator>=(const double other) const { return (value >= fix16_from_dbl(other)); } + int operator>=(const float other) const { return (value >= fix16_from_float(other)); } + int operator>=(const int16_t other) const { return (value >= fix16_from_int(other)); } - const int operator< (const Fix16 &other) const { return (value < other.value); } - const int operator< (const fix16_t other) const { return (value < other); } - const int operator< (const double other) const { return (value < fix16_from_dbl(other)); } - const int operator< (const float other) const { return (value < fix16_from_float(other)); } - const int operator< (const int16_t other) const { return (value < fix16_from_int(other)); } + int operator< (const Fix16 &other) const { return (value < other.value); } + int operator< (const fix16_t other) const { return (value < other); } + int operator< (const double other) const { return (value < fix16_from_dbl(other)); } + int operator< (const float other) const { return (value < fix16_from_float(other)); } + int operator< (const int16_t other) const { return (value < fix16_from_int(other)); } - const int operator> (const Fix16 &other) const { return (value > other.value); } - const int operator> (const fix16_t other) const { return (value > other); } - const int operator> (const double other) const { return (value > fix16_from_dbl(other)); } - const int operator> (const float other) const { return (value > fix16_from_float(other)); } - const int operator> (const int16_t other) const { return (value > fix16_from_int(other)); } + int operator> (const Fix16 &other) const { return (value > other.value); } + int operator> (const fix16_t other) const { return (value > other); } + int operator> (const double other) const { return (value > fix16_from_dbl(other)); } + int operator> (const float other) const { return (value > fix16_from_float(other)); } + int operator> (const int16_t other) const { return (value > fix16_from_int(other)); } Fix16 sin() const { return Fix16(fix16_sin(value)); } Fix16 cos() const { return Fix16(fix16_cos(value)); } diff --git a/libfixmath/fix16_exp.c b/libfixmath/fix16_exp.c index 747e77d..e804da1 100644 --- a/libfixmath/fix16_exp.c +++ b/libfixmath/fix16_exp.c @@ -15,8 +15,7 @@ fix16_t fix16_exp(fix16_t inValue) { if(inValue <= -772243 ) return 0; #ifndef FIXMATH_NO_CACHE - fix16_t tempIndex = (inValue ^ (inValue >> 16)); - tempIndex = (inValue ^ (inValue >> 4)) & 0x0FFF; + fix16_t tempIndex = (inValue ^ (inValue >> 4)) & 0x0FFF; if(_fix16_exp_cache_index[tempIndex] == inValue) return _fix16_exp_cache_value[tempIndex]; #endif