changeset 26192:6c482f11f9ad

Return "-1/0" for rational approximation of -Inf instead of "1/0". * oct-string.cc (rational_approx): Check sign of infinite value and return "-1/0" for -Inf.
author Rik <rik@octave.org>
date Mon, 10 Dec 2018 12:42:01 -0800
parents f41494a4977f
children 9aff537a5704
files liboctave/util/oct-string.cc
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/oct-string.cc	Sat Oct 05 02:21:10 2013 +0200
+++ b/liboctave/util/oct-string.cc	Mon Dec 10 12:42:01 2018 -0800
@@ -494,7 +494,12 @@
     len = 10;
 
   if (octave::math::isinf (val))
-    s = "1/0";
+    {
+      if (val > 0)
+        s = "1/0";
+      else
+        s = "-1/0";
+    }
   else if (octave::math::isnan (val))
     s = "0/0";
   else if (val < std::numeric_limits<int>::min ()