lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 1744d568 07/10: Regularize every mention of n


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 1744d568 07/10: Regularize every mention of nextafter()
Date: Mon, 20 Jun 2022 19:16:23 -0400 (EDT)

branch: master
commit 1744d568a9e2fb9bc50ebb87a7fa13283bee1a34
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Regularize every mention of nextafter()
    
    Include <cmath> (explaining why) wherever this function is used; and
    always write 'std::' before (to ensure that the overloaded C++ function
    is used: C99 has a type-generic version, but that's available only if
    <tgmath.h> in included).
---
 bourn_cast_test.cpp |  2 +-
 round_test.cpp      | 14 +++++++-------
 round_to_test.cpp   |  6 +++---
 tn_range.tpp        |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/bourn_cast_test.cpp b/bourn_cast_test.cpp
index 8cc19ef6..5f35b0e1 100644
--- a/bourn_cast_test.cpp
+++ b/bourn_cast_test.cpp
@@ -55,7 +55,7 @@ inline To bourn_cast(From from)
 #include "timer.hpp"
 
 #include <climits>                      // INT_MIN, LLONG_MIN, SCHAR_MIN
-#include <cmath>                        // isnormal()
+#include <cmath>                        // isnormal(), nextafterf()
 
 /// Test trivial casts between identical types.
 
diff --git a/round_test.cpp b/round_test.cpp
index 7395b8c4..45617015 100644
--- a/round_test.cpp
+++ b/round_test.cpp
@@ -41,7 +41,7 @@
 
 #include <algorithm>                    // max()
 #include <cfloat>                       // DECIMAL_DIG
-#include <cmath>                        // round()
+#include <cmath>                        // nextafter(), round()
 #include <ios>
 #include <iostream>
 #include <limits>
@@ -353,20 +353,20 @@ void test_rounding()
     // | 4503599627370498.
     //
     // The number above that's very close to one-half is in fact
-    //   nextafter(0.5, 0.0)
+    //   std::nextafter(0.5, 0.0)
     // both of which are ffffffffffffdf3f / 3fdfffffffffffff internally.
 
     test_various_float_types(4503599627370497.0L, 4503599627370497.0L);
 
     // This test:
-//    test_various_float_types(nextafter(0.5L, 0.0L), 0.0L);
+//    test_various_float_types(std::nextafter(0.5L, 0.0L), 0.0L);
     // mustn't be run as such because, e.g., the value
-    //   static_cast<float>(nextafter(0.5L, 0.0L))
+    //   static_cast<float>(std::nextafter(0.5L, 0.0L))
     // need not be distinct from 0.0F.
 
-    LMI_TEST((test_one_case(nextafterf(0.5F, 0.0F), 0.0F)));
-    LMI_TEST((test_one_case(nextafter (0.5 , 0.0 ), 0.0 )));
-    LMI_TEST((test_one_case(nextafterl(0.5L, 0.0L), 0.0L)));
+    LMI_TEST((test_one_case(std::nextafterf(0.5F, 0.0F), 0.0F)));
+    LMI_TEST((test_one_case(std::nextafter (0.5 , 0.0 ), 0.0 )));
+    LMI_TEST((test_one_case(std::nextafterl(0.5L, 0.0L), 0.0L)));
 }
 
 int test_all_modes(bool synchronize)
diff --git a/round_to_test.cpp b/round_to_test.cpp
index 6302f2b2..01be605b 100644
--- a/round_to_test.cpp
+++ b/round_to_test.cpp
@@ -33,7 +33,7 @@
 #include <algorithm>                    // max()
 #include <cfloat>                       // DECIMAL_DIG
 #include <climits>                      // INT_MIN
-#include <cmath>                        // fabs()
+#include <cmath>                        // fabs(), nextafter()
 #include <ios>
 #include <iostream>
 #include <limits>
@@ -547,8 +547,8 @@ void round_to_test::test_scaling()
 {
     scoped_ios_format meaningless_name(std::cout);
     double const volatile d0 = 2.71828'18284'59045'23536;
-    double const lo = nextafter(d0, -INFINITY);
-    double const hi = nextafter(d0,  INFINITY);
+    double const lo = std::nextafter(d0, -INFINITY);
+    double const hi = std::nextafter(d0,  INFINITY);
 
     double const volatile d1 = (d0 * 1.0e8) / 1.0e8;
     double const volatile dreciprocal = 1.0 / 1.0e8;
diff --git a/tn_range.tpp b/tn_range.tpp
index 4e215826..578a7d79 100644
--- a/tn_range.tpp
+++ b/tn_range.tpp
@@ -220,7 +220,7 @@ namespace
         return is_exact_integer_tester<T>()(t);
     }
 
-    /// Like C99 nextafter(), but prevents range error, and returns
+    /// Like std::nextafter(), but prevents range error, and returns
     /// exact integral values unchanged.
 
     template<typename T>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]