]> https://gitweb.dealii.org/ - dealii.git/commitdiff
TableHandler::set_scientific(): fix int 17751/head
authorPeter Munch <peterrmuench@gmail.com>
Sat, 5 Oct 2024 09:07:52 +0000 (11:07 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Tue, 8 Oct 2024 09:14:39 +0000 (11:14 +0200)
doc/news/changes/minor/20241005Munch [new file with mode: 0644]
source/base/table_handler.cc
tests/base/table_handler_10.cc
tests/base/table_handler_10.output

diff --git a/doc/news/changes/minor/20241005Munch b/doc/news/changes/minor/20241005Munch
new file mode 100644 (file)
index 0000000..0b1719f
--- /dev/null
@@ -0,0 +1,4 @@
+Improved: TableHandler now correctly outputs Integers if
+TableHandler::set_scientific() is set.
+<br>
+(Peter Munch, 2024/10/05)
index bb32bbc9ffa3cf609481f992c970f1942db32a5e..5ce1351085ff9310f0132312cfd999b29aa98d20 100644 (file)
@@ -90,7 +90,10 @@ namespace internal
     else
       ss.setf(std::ios::fixed, std::ios::floatfield);
 
-    std::visit([&ss](const auto &v) { ss << v; }, value);
+    if (scientific)
+      ss << get_numeric_value();
+    else
+      std::visit([&ss](const auto &v) { ss << v; }, value);
 
     cached_value = ss.str();
     if (cached_value.empty())
index a4a84a2138c539c318b16f2e3e26c1c1c6069ef7..0c5fd2c3589161002ad965fd6fd91f21c508a4fd 100644 (file)
@@ -36,15 +36,15 @@ main()
   std::string keys[3] = {"key1", "key2", "key3"};
 
   // fill rows 1 and 2 partially
-  table.add_value(keys[0], 0.0);
-  table.add_value(keys[0], 1.0);
+  table.add_value(keys[0], 0);
+  table.add_value(keys[0], 1);
   // now fill row 3 completely
-  table.add_value(keys[0], 2.0);
+  table.add_value(keys[0], 2);
   table.add_value(keys[1], 123.456);
   table.add_value(keys[2], std::string("abc"));
 
   // now again fill row 4 partially
-  table.add_value(keys[0], 1.0);
+  table.add_value(keys[0], 1);
 
   // produce output. hope that row 4 is
   // completely padded
index e4cc24e56d633cf08f9925331a227c63c410a0f8..165540898dce27cfd4792906a267fea03d4094c5 100644 (file)
@@ -2,10 +2,10 @@
 # 1: key1
 # 2: key2
 # 3: key3
-0.0000 0.0000   ""  
-1.0000 0.0000   ""  
-2.0000 123.4560 abc 
-1.0000 0.0000   ""  
+0 0.0000   ""  
+1 0.0000   ""  
+2 123.4560 abc 
+1 0.0000   ""  
 # 1: key1
 # 2: key2
 # 3: key3

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.