about summary refs log tree commit diff stats
path: root/032array.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 /032array.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 '032array.cc')
-rw-r--r--032array.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/032array.cc b/032array.cc
index 62021466..1b8d5900 100644
--- a/032array.cc
+++ b/032array.cc
@@ -156,7 +156,7 @@ case INDEX: {
   vector<double> offset_val(read_memory(offset));
   vector<type_ordinal> element_type = array_element(base.types);
   if (offset_val.at(0) < 0 || offset_val.at(0) >= Memory[base_address]) {
-    raise << current_recipe_name() << ": invalid index " << offset_val.at(0) << '\n' << end();
+    raise << current_recipe_name() << ": invalid index " << no_scientific(offset_val.at(0)) << '\n' << end();
     break;
   }
   long long int src = base_address + 1 + offset_val.at(0)*size_of(element_type);
@@ -251,7 +251,7 @@ case INDEX_ADDRESS: {
   vector<double> offset_val(read_memory(offset));
   vector<type_ordinal> element_type = array_element(base.types);
   if (offset_val.at(0) < 0 || offset_val.at(0) >= Memory[base_address]) {
-    raise << current_recipe_name() << ": invalid index " << offset_val.at(0) << '\n' << end();
+    raise << current_recipe_name() << ": invalid index " << no_scientific(offset_val.at(0)) << '\n' << end();
     break;
   }
   long long int result = base_address + 1 + offset_val.at(0)*size_of(element_type);