diff --git a/FixMath2.h b/FixMath2.h index fde651117..0b4285362 100644 --- a/FixMath2.h +++ b/FixMath2.h @@ -16,7 +16,7 @@ #include "IntegerType.h" -#define SHIFTR(x,bits) (bits > 0 ? x >> (bits) : x << (-bits)) // shift right for positive shift numbers, and left for negative ones. +#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) template // NI and NF being the number of bits for the integral and the fractionnal parts respectively. @@ -60,13 +60,20 @@ class UFixMath2 // Multiplication overload, returns the compound type - template - UFixMath2 operator* (const UFixMath2<_NI,_NF>& op) + /* template + const UFixMath2 operator* (const UFixMath2<_NI,_NF>& op) { typedef typename IntegerType< ((NI+_NI+NF+_NF-1)>>3)+1>::unsigned_type return_type ; return_type tt = return_type(internal_value)*op.getInt(); return UFixMath2(tt,true); + }*/ + template + UFixMath2 operator* (const UFixMath2<_NI,_NF>& op) const + { + typedef typename IntegerType< ((NI+_NI+NF+_NF-1)>>3)+1>::unsigned_type return_type ; + return_type tt = return_type(internal_value)*op.getInt(); + return UFixMath2(tt,true); } @@ -85,7 +92,7 @@ class UFixMath2 float asFloat() { return (static_cast(internal_value)) / (next_greater_type(1)<