lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 2c8cc917 04/11: Don't bother calculating 2^64


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 2c8cc917 04/11: Don't bother calculating 2^64 - 1
Date: Tue, 31 May 2022 17:52:05 -0400 (EDT)

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

    Don't bother calculating 2^64 - 1
    
    In two's complement unsigned 64-bit integer arithmetic,
      (((((2^2)^2)^2)^2)^2)^2 = 0
    Doing that with only six multiplications instead of sixty-three
    isn't terribly impressive when zero multiplications suffice.
---
 ul_utilities_test.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/ul_utilities_test.cpp b/ul_utilities_test.cpp
index 45992c67..9f8f78bf 100644
--- a/ul_utilities_test.cpp
+++ b/ul_utilities_test.cpp
@@ -26,7 +26,6 @@
 #include "bourn_cast.hpp"
 #include "materially_equal.hpp"
 #include "round_to.hpp"
-#include "stl_extensions.hpp"           // nonstd::power()
 #include "test_tools.hpp"
 
 #include <cfenv>                        // fesetround()
@@ -80,8 +79,7 @@ void test_max_modal_premium()
 
     // Decimal values of certain constants.
 
-    LMI_TEST_EQUAL(18446744073709551615ULL      , UINT64_MAX);
-    LMI_TEST_EQUAL(18446744073709551615ULL      , nonstd::power(2ULL, 64) - 1);
+    LMI_TEST_EQUAL(18446744073709551615ULL      , UINT64_MAX); // 2^64 - 1
     LMI_TEST_EQUAL(184467440737ULL              , UINT64_MAX / 100000000);
     // Same, with dollars-and-cents separators:
     LMI_TEST_EQUAL(184'467'440'737'095'516'15ULL, UINT64_MAX);



reply via email to

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