[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 358c5c9 06/13: Modernize
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 358c5c9 06/13: Modernize |
Date: |
Fri, 9 Apr 2021 18:42:37 -0400 (EDT) |
branch: master
commit 358c5c9e306b91e73aafdab49e482fda32adf192
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Modernize
C99 can be assumed and need no longer be emulated.
---
round_test.cpp | 9 ++-------
round_to_test.cpp | 9 ++-------
2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/round_test.cpp b/round_test.cpp
index 1bc9011..215a25f 100644
--- a/round_test.cpp
+++ b/round_test.cpp
@@ -39,6 +39,7 @@
#include "test_tools.hpp"
#include <algorithm> // max()
+#include <cfloat> // DECIMAL_DIG
#include <cmath> // round()
#include <ios>
#include <iostream>
@@ -203,13 +204,7 @@ bool test_one_case
if(!error_is_within_tolerance)
{
std::cout << '\n';
- // Use enough precision to map the base-ten scientific
- // representation back to binary without loss of accuracy.
- // Cf. C99 5.2.4.2.2/8 (DECIMAL_DIG).
- int nbits = std::numeric_limits<RealType>::digits;
- std::streamsize old_precision = std::cout.precision
- (1 + static_cast<int>(std::ceil(std::log10(std::pow(2.0, nbits))))
- );
+ std::streamsize old_precision = std::cout.precision(DECIMAL_DIG);
std::ios_base::fmtflags old_flags = std::cout.flags();
std::cout
diff --git a/round_to_test.cpp b/round_to_test.cpp
index ca45a1a..54c5db8 100644
--- a/round_to_test.cpp
+++ b/round_to_test.cpp
@@ -29,6 +29,7 @@
#include "test_tools.hpp"
#include <algorithm> // max()
+#include <cfloat> // DECIMAL_DIG
#include <climits> // INT_MIN
#include <ios>
#include <iostream>
@@ -243,13 +244,7 @@ bool round_to_test::test_one_case
if(!error_is_within_tolerance)
{
std::cout << '\n';
- // Use enough precision to map the base-ten scientific
- // representation back to binary without loss of accuracy.
- // Cf. C99 5.2.4.2.2/8 (DECIMAL_DIG).
- int nbits = std::numeric_limits<RealType>::digits;
- std::streamsize old_precision = std::cout.precision
- (1 + static_cast<int>(std::ceil(std::log10(std::pow(2.0, nbits))))
- );
+ std::streamsize old_precision = std::cout.precision(DECIMAL_DIG);
std::ios_base::fmtflags old_flags = std::cout.flags();
std::cout
- [lmi-commits] [lmi] master updated (8aa09b9 -> a32cee0), Greg Chicares, 2021/04/09
- [lmi-commits] [lmi] master 79741b1 01/13: Assert a precondition more consistently, Greg Chicares, 2021/04/09
- [lmi-commits] [lmi] master 358c5c9 06/13: Modernize,
Greg Chicares <=
- [lmi-commits] [lmi] master edb098f 02/13: Strengthen unit tests, Greg Chicares, 2021/04/09
- [lmi-commits] [lmi] master 2a3d961 03/13: Measure cost of a needless transcendental calculation, Greg Chicares, 2021/04/09
- [lmi-commits] [lmi] master 6bc828a 05/13: Realign, Greg Chicares, 2021/04/09
- [lmi-commits] [lmi] master 290dc89 10/13: Remove a source of inaccuracy [285], Greg Chicares, 2021/04/09
- [lmi-commits] [lmi] master a32cee0 13/13: Hoist a division, Greg Chicares, 2021/04/09
- [lmi-commits] [lmi] master 1e49ee3 04/13: Revise 'round_to' documentation [286], Greg Chicares, 2021/04/09
- [lmi-commits] [lmi] master 1bead9e 08/13: Purge unwanted, commented-out code, Greg Chicares, 2021/04/09
- [lmi-commits] [lmi] master ce9ed5c 07/13: Add an inchoate test of power-of-ten scaling, Greg Chicares, 2021/04/09
- [lmi-commits] [lmi] master 858d037 09/13: Include appropriate headers, and say why they're included, Greg Chicares, 2021/04/09
- [lmi-commits] [lmi] master ca63009 11/13: Expunge an obsolete comment, Greg Chicares, 2021/04/09