octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54572] int64 does not saturate correctly in n


From: Dan Sebald
Subject: [Octave-bug-tracker] [bug #54572] int64 does not saturate correctly in negative direction
Date: Tue, 28 Aug 2018 02:34:44 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0

Follow-up Comment #5, bug #54572 (project octave):

I'll compile the latest code while typing...

Yes, it may be the non-symmetry of ints that is at issue.  However, this fails
as well:

+verbatim-
octave:6> int64 (-2) - intmax ('int64')
ans = 9223372036854775807
octave:5> int64 (-1) - intmax ('int64')
ans = -9223372036854775808


so it wouldn't seem that in both cases (-y) is negating the higher magnitude
extrema.  If that were the case, it would be a compiler bug.

... OK, recompiled, and I added the following:


diff --git a/liboctave/util/oct-inttypes.cc b/liboctave/util/oct-inttypes.cc
--- a/liboctave/util/oct-inttypes.cc
+++ b/liboctave/util/oct-inttypes.cc
@@ -28,6 +28,7 @@ along with Octave; see the file COPYING.
 #include "fpucw-wrappers.h"
 #include "lo-error.h"
 #include "oct-inttypes.h"
+#include <iostream>
 
 template <typename T>
 const octave_int<T> octave_int<T>::zero (static_cast<T> (0));
@@ -480,6 +481,9 @@ DOUBLE_INT_BINOP_DECL (+, int64)
 
 INT_DOUBLE_BINOP_DECL (-, uint64)
 {
+std::cerr << "I AM HERE\n";
+std::cerr << "x = " << x << "\n";
+std::cerr << "(-y) = " << (-y) << "\n";
   return x + (-y);
 }
 


However, I'm not seeing the output when testing:


octave:3> intmin ('int64') - int64 (1)
ans = 9223372036854775807
octave:4> intmin ('int64') - int64 (2)
ans = 9223372036854775807
octave:5> intmin ('int64') - int64 (3)
ans = 9223372036854775807


Strange.  I will investigate...

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?54572>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]