[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 8b6d6dd8 12/13: Say DECIMAL_DIG wherever it's
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 8b6d6dd8 12/13: Say DECIMAL_DIG wherever it's meant |
Date: |
Mon, 9 May 2022 20:13:18 -0400 (EDT) |
branch: master
commit 8b6d6dd8ea1d59a69fc72cd929b51d14758871bf
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Say DECIMAL_DIG wherever it's meant
"21" is not descriptive, and std::numeric_limits<T>::max_digits10 is
abominable.
---
irc7702_tables_test.cpp | 8 ++++----
null_stream_test.cpp | 3 ++-
ul_utilities.cpp | 4 ++--
ul_utilities_test.cpp | 3 ++-
zero_test.cpp | 6 +++---
5 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/irc7702_tables_test.cpp b/irc7702_tables_test.cpp
index 73df722b..fc6661dd 100644
--- a/irc7702_tables_test.cpp
+++ b/irc7702_tables_test.cpp
@@ -30,7 +30,7 @@
#include "ssize_lmi.hpp"
#include "test_tools.hpp"
-#include <cfloat> // DBL_EPSILON
+#include <cfloat> // DBL_EPSILON, DECIMAL_DIG
#include <cmath> // log()
#include <vector>
@@ -1042,7 +1042,7 @@ void irc7702_tables_test::test_1980_cso()
double const observed = ol_nsp[0];
double const expected = olcf_1980_cso_endt_100[0].Ax;
- std::cout.precision(21);
+ std::cout.precision(DECIMAL_DIG);
std::cout
<< "Initial Ax (the most sensitive value) for 1980 CSO:"
<< "\n spreadsheet: " << expected
@@ -1086,7 +1086,7 @@ void irc7702_tables_test::test_2001_cso()
double const observed = ol_nsp[0];
double const expected = olcf_2001_cso_endt_100[0].Ax;
- std::cout.precision(21);
+ std::cout.precision(DECIMAL_DIG);
std::cout
<< "Initial Ax (the most sensitive value) for 2001 CSO:"
<< "\n spreadsheet: " << expected
@@ -1130,7 +1130,7 @@ void irc7702_tables_test::test_2017_cso()
double const observed = ol_nsp[0];
double const expected = olcf_2017_cso_endt_95[0].Ax;
- std::cout.precision(21);
+ std::cout.precision(DECIMAL_DIG);
std::cout
<< "Initial Ax (the most sensitive value) for 2017 CSO:"
<< "\n spreadsheet: " << expected
diff --git a/null_stream_test.cpp b/null_stream_test.cpp
index 2945070f..2ef80d10 100644
--- a/null_stream_test.cpp
+++ b/null_stream_test.cpp
@@ -27,6 +27,7 @@
#include "test_tools.hpp"
#include "timer.hpp"
+#include <cfloat> // DECIMAL_DIG
#include <fstream>
#include <iomanip>
#include <sstream>
@@ -68,7 +69,7 @@ void emit_text_to_stream(std::ostream& os)
<< std::flush
;
os
- << std::setprecision(21)
+ << std::setprecision(DECIMAL_DIG)
<< std::setw(12) << 3.14159
<< std::fixed
<< std::hex
diff --git a/ul_utilities.cpp b/ul_utilities.cpp
index 8e681e6c..744007b5 100644
--- a/ul_utilities.cpp
+++ b/ul_utilities.cpp
@@ -125,8 +125,8 @@ currency rate_times_currency
if(!materially_equal(bourn_cast<double>(irate), rate * radix))
{
#if 0
- // Enable this (including <iostream>) for research.
- std::cout.precision(21);
+ // Enable this (including <iostream> and <cfloat>) for research.
+ std::cout.precision(DECIMAL_DIG);
std::cout
<< "Excessive precision in rate; check the table\n"
<< bourn_cast<double>(irate) << " bourn_cast<double>(irate)\n"
diff --git a/ul_utilities_test.cpp b/ul_utilities_test.cpp
index f2767965..6c76340a 100644
--- a/ul_utilities_test.cpp
+++ b/ul_utilities_test.cpp
@@ -29,13 +29,14 @@
#include "test_tools.hpp"
#include <cfenv> // fesetround()
+#include <cfloat> // DECIMAL_DIG
#include <cmath> // nearbyint()
#include <cstdint> // int64_t
void test_max_modal_premium()
{
// This affects diagnostics shown when LMI_TEST_EQUAL() fails.
- std::cout.precision(21);
+ std::cout.precision(DECIMAL_DIG);
// These are generally useful for testing.
round_to<double> const round_down(2, r_downward);
diff --git a/zero_test.cpp b/zero_test.cpp
index c9f26d95..2256e3e4 100644
--- a/zero_test.cpp
+++ b/zero_test.cpp
@@ -861,7 +861,7 @@ void test_celebrated_equation()
auto f = [](double x) {return x * x * x - 2.0 * x - 5.0;};
std::ostringstream oss;
oss.precision(17);
- root_type r = decimal_root(f, -2.56, 2.56, bias_none, 21, oss);
+ root_type r = decimal_root(f, -2.56, 2.56, bias_none, DECIMAL_DIG, oss);
LMI_TEST(root_is_valid == r.validity);
// This constant is from the cited blog; lmi yields this,
// which agrees to sixteen significant digits:
@@ -1360,7 +1360,7 @@ b = 1;
// s_stop("", (ftnlen)0);
//std::cout << "Number of evaluations = " << n_eval << std::endl;
-//std::cout.precision(21);
+//std::cout.precision(DECIMAL_DIG);
//std::cout << "Computed root = " << root << std::endl;
} // end test adapted from 'driver.f'
@@ -1374,7 +1374,7 @@ b = 1;
auto f = [](double x) {return std::sin(x) - x / 2.0;};
- std::cout.precision(21);
+ std::cout.precision(DECIMAL_DIG);
root_type r = lmi_root(f, bound0, bound1, 0.0);
double const validated = r.root;
- [lmi-commits] [lmi] master 3903eed7 03/13: Include appropriate headers, and say why they're included, (continued)
- [lmi-commits] [lmi] master 3903eed7 03/13: Include appropriate headers, and say why they're included, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master d9c5f0d5 04/13: Use a local alias to shorten expressions, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master 3d69769b 05/13: Demonstrate that a default comparison tolerance works well, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master 4d7fe889 07/13: Use rate_times_currency(), Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master 03ad37d7 08/13: Note an arcanum, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master a67210ec 10/13: Better explain the purpose of each block of unit tests, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master ee272a29 02/13: Suppress certain GTK diagnostics, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master c768da7e 06/13: Refactor, almost, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master 35eb8545 09/13: Prefer a calculation with less roundoff error, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master c53ea12a 11/13: Reorder some statements in a unit test, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master 8b6d6dd8 12/13: Say DECIMAL_DIG wherever it's meant,
Greg Chicares <=
- [lmi-commits] [lmi] master 3903a0c3 13/13: Record speed measurements, Greg Chicares, 2022/05/09