[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #56941] format rat or rats display 0 rather th
From: |
John W. Eaton |
Subject: |
[Octave-bug-tracker] [bug #56941] format rat or rats display 0 rather than rational approximation for small numbers |
Date: |
Mon, 23 Sep 2019 16:38:14 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 |
Follow-up Comment #1, bug #56941 (project octave):
I'm not sure how to print the contents of an ostringstream object with gdb, so
I used the simple change shown below. I found that Octave computes the same
value as Matlab for the test case but then bails out and returns "0" because
the output is considered too wide. I don't know what the proper fix is since
I'm not sure why we impose a limit on the output width.
diff --git a/liboctave/util/oct-string.cc b/liboctave/util/oct-string.cc
--- a/liboctave/util/oct-string.cc
+++ b/liboctave/util/oct-string.cc
@@ -23,6 +23,8 @@ along with Octave; see the file COPYING.
# include "config.h"
#endif
+#include <iostream>
+
#include "oct-string.h"
#include <algorithm>
@@ -624,8 +626,12 @@ rational_approx (T val, int len)
if (buf.str ().length () > static_cast<unsigned int> (len +
2))
break;
}
- else if (buf.str ().length () > static_cast<unsigned int> (len))
- break;
+ else
+ {
+ std::cerr << "buf: " << buf.str () << std::endl;
+ if (buf.str ().length () > static_cast<unsigned int> (len))
+ break;
+ }
if (std::abs (n) > std::numeric_limits<int>::max ()
|| std::abs (d) > std::numeric_limits<int>::max ())
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?56941>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/