From b6ae357c63d28fd428a4b9efcf1ec575dbca6881 Mon Sep 17 00:00:00 2001 From: tomcombriat Date: Sun, 19 Nov 2023 17:06:21 +0100 Subject: [PATCH] Small cleanup --- FixMath2.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/FixMath2.h b/FixMath2.h index 9b0c69501..a00ea99eb 100644 --- a/FixMath2.h +++ b/FixMath2.h @@ -19,9 +19,9 @@ #define SHIFTR(x,bits) (bits > 0 ? (x >> (bits)) : (x << (-bits))) // shift right for positive shift numbers, and left for negative ones. #define MAX(N1,N2) (N1 > N2 ? N1 : N2) /*#define NBITSREAL(X,N) (abs(X) < (1<(X))*/ -//#define UFixAuto(X) (UFixMath2(X)) + #define NBITSREAL2(X,N) (abs(X) < (1<(X)) + #define UFixAuto(X) (UFixMath2(X))*/ /* template @@ -102,10 +102,10 @@ class UFixMath2 } /* Constructor from Sfixed type */ - template + template UFixMath2(const SFixMath2<_NI,_NF>& uf) { internal_value = SHIFTR((typename IntegerType<((MAX(NI+NF-1,_NI+_NF-1))>>3)+1>::unsigned_type) uf.asRaw(),(_NF-NF)); - } + } //////// ADDITION OVERLOADS @@ -154,11 +154,11 @@ class UFixMath2 return UFixMath2(internal_value-((internal_type)op< operator-() const + /////// Negative overload + SFixMath2 operator-() const { - return SFixMath2( -(typename IntegerType<((NI+NF-1+1)>>3)+1>::signed_type)(internal_value),true); - } + return SFixMath2( -(typename IntegerType<((NI+NF-1+1)>>3)+1>::signed_type)(internal_value),true); + } //////// MULTIPLICATION OVERLOADS @@ -609,7 +609,7 @@ SFixMath2 operator* (const UFixMath2& op1, const SFixMat } -// Addition between SFixMath2 and UFixMath2 (promotion to SFixMath2) +// Addition between SFixMath2 and UFixMath2 (promotion to next SFixMath2) template SFixMath2 operator+ (const SFixMath2& op1, const UFixMath2<_NI,_NF>& op2 ) @@ -630,7 +630,7 @@ SFixMath2 operator+ (const UFixMath2& op1, con return op2+op1; } -// Substraction between SFixMath2 and UFixMath2 (promotion to SFixMath2) +// Substraction between SFixMath2 and UFixMath2 (promotion to next SFixMath2) template SFixMath2 operator- (const SFixMath2& op1, const UFixMath2<_NI,_NF>& op2 )