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 /031address.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 '031address.cc')
-rw-r--r-- | 031address.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/031address.cc b/031address.cc index 997e3c65..38a891ef 100644 --- a/031address.cc +++ b/031address.cc @@ -64,7 +64,7 @@ reagent lookup_memory(reagent x) { return result; } result.set_value(Memory[x.value]); - trace(Primitive_recipe_depth, "mem") << "location " << x.value << " is " << result.value << end(); + trace(Primitive_recipe_depth, "mem") << "location " << x.value << " is " << no_scientific(result.value) << end(); // populate types copy(++x.types.begin(), x.types.end(), inserter(result.types, result.types.begin())); @@ -147,7 +147,7 @@ Recipe_ordinal["$dump"] = _DUMP; :(before "End Primitive Recipe Implementations") case _DUMP: { reagent after_canonize = canonize(current_instruction().ingredients.at(0)); - cerr << current_recipe_name() << ": " << current_instruction().ingredients.at(0).name << ' ' << current_instruction().ingredients.at(0).value << " => " << after_canonize.value << " => " << Memory[after_canonize.value] << '\n'; + cerr << current_recipe_name() << ": " << current_instruction().ingredients.at(0).name << ' ' << no_scientific(current_instruction().ingredients.at(0).value) << " => " << no_scientific(after_canonize.value) << " => " << no_scientific(Memory[after_canonize.value]) << '\n'; break; } @@ -162,7 +162,7 @@ Recipe_ordinal["$foo"] = _FOO; :(before "End Primitive Recipe Implementations") case _FOO: { if (current_instruction().ingredients.empty()) { - if (foo != -1) cerr << foo << ": " << Memory[foo] << '\n'; + if (foo != -1) cerr << foo << ": " << no_scientific(Memory[foo]) << '\n'; else cerr << '\n'; } else { |