From 4082acd24f0049604f840fb5e60977e247aafbdf Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 14 Sep 2015 23:30:03 -0700 Subject: 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. --- 029tools.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to '029tools.cc') 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& 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)); } } } -- cgit 1.4.1-2-gfad0