Kaynağa Gözat

merging redundant sprintf code and fixing an operator<< fixedpoint bug

Roberto Parolin 6 yıl önce
ebeveyn
işleme
2bad24e6bd

+ 2 - 2
include/EAStdC/EAFixedPoint.h

@@ -283,8 +283,8 @@ struct FPTemplate
 	FPTemplate& operator^=(const FPTemplate& argValue) { value ^= argValue.value;          return *this;}
 	FPTemplate& operator^=(const FPTemplate& argValue) { value ^= argValue.value;          return *this;}
 	FPTemplate& operator^=(const int&        argValue) { value ^= (argValue<<upShiftInt);  return *this;} //Convert Fixed to int, then do operation
 	FPTemplate& operator^=(const int&        argValue) { value ^= (argValue<<upShiftInt);  return *this;} //Convert Fixed to int, then do operation
 
 
-	FPTemplate operator<<(int numBits) const { return value << numBits; }
-	FPTemplate operator>>(int numBits) const { return value << numBits; }
+	FPTemplate operator<<(int numBits) const { FPTemplate temp; temp.value = value << numBits; return temp; }
+	FPTemplate operator>>(int numBits) const { FPTemplate temp; temp.value = value >> numBits; return temp; }
 
 
 	FPTemplate& operator<<=(int numBits) { value <<= numBits; return *this;}
 	FPTemplate& operator<<=(int numBits) { value <<= numBits; return *this;}
 	FPTemplate& operator>>=(int numBits) { value >>= numBits; return *this;}
 	FPTemplate& operator>>=(int numBits) { value >>= numBits; return *this;}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 311 - 1078
source/EASprintfOrdered.cpp


+ 38 - 0
test/source/TestFixedPoint.cpp

@@ -129,6 +129,44 @@ int TestFixedPoint()
 			nErrorCount++;
 			nErrorCount++;
 	}
 	}
 
 
+	{
+		// FPTemplate operator<<(int numBits) const 
+		{
+			SFixed16 a(16);
+
+			auto expected = a.value << 1;
+
+			a = (a << 1);
+
+			if(!CompareValues(a.value, expected))
+				nErrorCount++;
+		}
+
+		// FPTemplate operator>>(int numBits) const 
+		{
+			SFixed16 a(16);
+
+			auto expected = a.value >> 1;
+
+			a = (a >> 1);
+
+			if(!CompareValues(a.value, expected))
+				nErrorCount++;
+		}
+	}
+
+	// Reported regression - ensure operator<< and operator>> are implemented correctly.
+	{
+		SFixed16 a(16);
+
+		auto expected = a.value;
+
+		a = (a << 1);
+		a = (a >> 1);
+
+		if(!CompareValues(a.value, expected))
+			nErrorCount++;
+	}
 
 
 	#ifndef EA_DLL
 	#ifndef EA_DLL
 		// Test SFixed24
 		// Test SFixed24

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor