changeset 6764:2a83fce5a097

[project @ 2007-06-27 19:02:59 by dbateman]
author dbateman
date Wed, 27 Jun 2007 19:02:59 +0000
parents 958713bc465e
children e6b528a3a2a9
files liboctave/ChangeLog liboctave/oct-inttypes.h
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Wed Jun 27 18:34:13 2007 +0000
+++ b/liboctave/ChangeLog	Wed Jun 27 19:02:59 2007 +0000
@@ -1,3 +1,10 @@
+2007-06-04  David Bateman  <dbateman@free.fr>
+
+	* oct-inttypes.h (octave_int<T>& operator <<= (const T2&),
+	octave_int<T>& operator >>= (const T2&)): Make shift operators
+	perform a twos complement arithmetic shift for both signed and
+	unsigned integers regardless of compiler implementations.
+
 2007-06-13  Michael Goffioul  <michael.goffioul@swing.be>
 
 	* SparseCmplxQR.cc (OCTAVE_C99_ZERO): For CXSparse 2.2 and greater
--- a/liboctave/oct-inttypes.h	Wed Jun 27 18:34:13 2007 +0000
+++ b/liboctave/oct-inttypes.h	Wed Jun 27 19:02:59 2007 +0000
@@ -295,14 +295,17 @@
   template <class T2>
   octave_int<T>& operator <<= (const T2& x)
   {
-    ival = ((ival << x) > std::numeric_limits<T>::max ()) ? 0 : (ival << x);
+    ival = ival << x;
     return *this;
   }
 
   template <class T2>
   octave_int<T>& operator >>= (const T2& x)
   {
-    ival >>= x;
+    if (ival < 0)
+      ival = - (((-ival) >> x) & std::numeric_limits<T>::max());
+    else
+      ival = ival >> x;
     return *this;
   }