lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master e10d8da5 2/3: Use long long int, now that it'


From: Greg Chicares
Subject: [lmi-commits] [lmi] master e10d8da5 2/3: Use long long int, now that it's standard
Date: Fri, 27 May 2022 20:49:11 -0400 (EDT)

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

    Use long long int, now that it's standard
    
    Here, max() is of type T, so 'auto' DTRT; and it's already constexpr:
    - long int z1 = std::numeric_limits<long int>::max();
    + constexpr auto z1 = std::numeric_limits<long long int>::max();
---
 tn_range.tpp | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tn_range.tpp b/tn_range.tpp
index 5bcb1069..563cb037 100644
--- a/tn_range.tpp
+++ b/tn_range.tpp
@@ -148,10 +148,8 @@ namespace
     /// A value of floating type is considered exact iff
     ///  - it is in the range that the floating-point type could
     ///    represent exactly; and
-    ///  - it is in the range of long int; and
-    ///  - converting it to type long int preserves its value.
-    /// Type long long int might have been used instead, but it is not
-    /// yet part of standard C++ and not all compilers support it.
+    ///  - it is in the range of long long int; and
+    ///  - converting it to type long long int preserves its value.
     ///
     /// No nonfundamental type is considered exact.
     ///
@@ -189,17 +187,18 @@ namespace
                 (static_cast<T>(std::numeric_limits<T>::radix)
                 ,static_cast<T>(std::numeric_limits<T>::digits)
                 );
-            long int z1 = std::numeric_limits<long int>::max();
+            constexpr auto z1 = std::numeric_limits<long long int>::max();
 #if defined __GNUC__
 #   pragma GCC diagnostic push
 #   pragma GCC diagnostic ignored "-Wconversion"
+#   pragma GCC diagnostic ignored "-Wfloat-conversion"
 #endif // defined __GNUC__
             return
                    -z0 < t
                 &&       t < z0
                 && -z1 < t
                 &&       t < z1
-                && t == static_cast<long int>(t)
+                && t == static_cast<long long int>(t)
                 ;
 #if defined __GNUC__
 #   pragma GCC diagnostic pop



reply via email to

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