This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] tr1::subtract_with_carry_01 tweak


Hi,

tested x86-linux, committed.

Paolo.

////////////////////
2006-08-22  Paolo Carlini  <pcarlini@suse.de>

	* include/tr1/random.tcc (subtract_with_carry_01<>::
      	seed(_Gen&, false_type)): Fix _M_carry initialization.
	
	* testsuite/tr1/5_numerical_facilities/random/
	subtract_with_carry/cons/default.cc: Qualify 1 as 1UL.
	* testsuite/tr1/5_numerical_facilities/random/
	subtract_with_carry/cons/gen1.cc: Likewise.
Index: include/tr1/random.tcc
===================================================================
--- include/tr1/random.tcc	(revision 116327)
+++ include/tr1/random.tcc	(working copy)
@@ -484,7 +484,15 @@
 	    _M_x[__i][__n - 1] = __mod<_UInt32Type, 1, 0,
 	      _Shift<_UInt32Type, __w % 32>::__value>(__gen());
 	  }
-	_M_carry = (_M_x[long_lag - 1][0] == 0) ? 1 : 0;
+
+	_M_carry = 1;
+	for (int __j = 0; __j < __n; ++__j)
+	  if (_M_x[long_lag - 1][__j] != 0)
+	    {
+	      _M_carry = 0;
+	      break;
+	    }
+
 	_M_p = 0;
 
 	// Initialize the array holding the negative powers of 2.
Index: testsuite/tr1/5_numerical_facilities/random/subtract_with_carry/cons/default.cc
===================================================================
--- testsuite/tr1/5_numerical_facilities/random/subtract_with_carry/cons/default.cc	(revision 116327)
+++ testsuite/tr1/5_numerical_facilities/random/subtract_with_carry/cons/default.cc	(working copy)
@@ -32,7 +32,7 @@
 
   subtract_with_carry<unsigned long, (1UL << 24), 10, 24> x;
   VERIFY( x.min() == 0 );
-  VERIFY( x.max() == ((1<<24)-1) );
+  VERIFY( x.max() == ((1UL << 24) - 1) );
   VERIFY( x() == 15039276 );
 }
 
Index: testsuite/tr1/5_numerical_facilities/random/subtract_with_carry/cons/gen1.cc
===================================================================
--- testsuite/tr1/5_numerical_facilities/random/subtract_with_carry/cons/gen1.cc	(revision 116327)
+++ testsuite/tr1/5_numerical_facilities/random/subtract_with_carry/cons/gen1.cc	(working copy)
@@ -40,7 +40,7 @@
 
   subtract_with_carry<unsigned long, (1UL << 24), 10, 24> x(gen);
   VERIFY( x.min() == 0 );
-  VERIFY( x.max() == ((1 << 24) - 1) );
+  VERIFY( x.max() == ((1UL << 24) - 1) );
 }
 
 int main()

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]