# HG changeset patch # User dbateman # Date 1182970979 0 # Node ID 2a83fce5a09737534d070145b1db9ba647c75aec # Parent 958713bc465e40fd2b786ab46bb83eb820a39b5f [project @ 2007-06-27 19:02:59 by dbateman] diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2007-06-04 David Bateman + + * oct-inttypes.h (octave_int& operator <<= (const T2&), + octave_int& 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 * SparseCmplxQR.cc (OCTAVE_C99_ZERO): For CXSparse 2.2 and greater diff --git a/liboctave/oct-inttypes.h b/liboctave/oct-inttypes.h --- a/liboctave/oct-inttypes.h +++ b/liboctave/oct-inttypes.h @@ -295,14 +295,17 @@ template octave_int& operator <<= (const T2& x) { - ival = ((ival << x) > std::numeric_limits::max ()) ? 0 : (ival << x); + ival = ival << x; return *this; } template octave_int& operator >>= (const T2& x) { - ival >>= x; + if (ival < 0) + ival = - (((-ival) >> x) & std::numeric_limits::max()); + else + ival = ival >> x; return *this; }