diff src/oct-stream.cc @ 6865:c40c71200c65

[project @ 2007-09-05 18:26:30 by jwe]
author jwe
date Wed, 05 Sep 2007 18:26:30 +0000
parents a6c8000f113e
children 3113e481833f
line wrap: on
line diff
--- a/src/oct-stream.cc
+++ b/src/oct-stream.cc
@@ -2618,8 +2618,17 @@
 		      if (lo_ieee_isnan (val) || xisinf (val))
 			{
 			  std::string tfmt = fmt;
-
-			  tfmt.replace (tfmt.rfind (elt->type), 1, 1, 's');
+			  std::string::size_type i1, i2;
+
+			  tfmt.replace ((i1 = tfmt.rfind (elt->type)),
+					1, 1, 's');
+
+			  if ((i2 = tfmt.rfind ('.')) != NPOS && i2 < i1)
+			    {
+			      tfmt.erase (i2, i1-i2);
+			      if (elt->prec < 0)
+				nsa--;
+			    }
 
 			  const char *tval = xisinf (val)
 			    ? (val < 0 ? "-Inf" : "Inf")