diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-09-14 23:30:03 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-09-14 23:37:12 -0700 |
commit | 4082acd24f0049604f840fb5e60977e247aafbdf (patch) | |
tree | ee0e15149954af80c20f010c47b2f412961ee199 /020run.cc | |
parent | e28fa5f1508ef7ffeb0b72406558534928c28f9e (diff) | |
download | mu-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 '020run.cc')
-rw-r--r-- | 020run.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/020run.cc b/020run.cc index be127989..d6ce68ec 100644 --- a/020run.cc +++ b/020run.cc @@ -270,7 +270,7 @@ vector<double> read_memory(reagent x) { long long int size = size_of(x); for (long long int offset = 0; offset < size; ++offset) { double val = Memory[base+offset]; - trace(Primitive_recipe_depth, "mem") << "location " << base+offset << " is " << val << end(); + trace(Primitive_recipe_depth, "mem") << "location " << base+offset << " is " << no_scientific(val) << end(); result.push_back(val); } return result; @@ -285,7 +285,7 @@ void write_memory(reagent x, vector<double> data) { return; } for (long long int offset = 0; offset < SIZE(data); ++offset) { - trace(Primitive_recipe_depth, "mem") << "storing " << data.at(offset) << " in location " << base+offset << end(); + trace(Primitive_recipe_depth, "mem") << "storing " << no_scientific(data.at(offset)) << " in location " << base+offset << end(); Memory[base+offset] = data.at(offset); } } |