about summary refs log tree commit diff stats
path: root/029tools.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-09-14 23:30:03 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-09-14 23:37:12 -0700
commit4082acd24f0049604f840fb5e60977e247aafbdf (patch)
treeee0e15149954af80c20f010c47b2f412961ee199 /029tools.cc
parente28fa5f1508ef7ffeb0b72406558534928c28f9e (diff)
downloadmu-4082acd24f0049604f840fb5e60977e247aafbdf.tar.gz
2199 - stop printing numbers in scientific notation
Turns out the default format for printing floating point numbers is
neither 'scientific' nor 'fixed' even though those are the only two
options offered. Reading the C++ standard I found out that the default
(modulo locale changes) is basically the same as the printf "%g" format.
And "%g" is basically the shorter of:
  a) %f with trailing zeros trimmed
  b) %e
So we'll just do %f and trim trailing zeros.
Diffstat (limited to '029tools.cc')
-rw-r--r--029tools.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/029tools.cc b/029tools.cc
index b03635b0..0011c6e0 100644
--- a/029tools.cc
+++ b/029tools.cc
@@ -76,7 +76,7 @@ string print_mu(const reagent& r, const vector<double>& data) {
   // End print Special-cases(reagent r, data)
   ostringstream out;
   for (long long i = 0; i < SIZE(data); ++i) {
-    out << data.at(i) << ' ';
+    out << no_scientific(data.at(i)) << ' ';
   }
   return out.str();
 }
@@ -215,7 +215,7 @@ case _PRINT: {
       for (long long int j = 0; j < SIZE(ingredients.at(i)); ++j) {
         trace(Primitive_recipe_depth, "run") << "$print: " << ingredients.at(i).at(j) << end();
         if (j > 0) cout << " ";
-        cout << ingredients.at(i).at(j);
+        cout << no_scientific(ingredients.at(i).at(j));
       }
     }
   }