[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);
- [lmi-commits] [lmi] master updated (44ea8a5b -> fd325f5e), Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master d36e5145 03/11: Suppress undefined behavior; add a test with defined behavior, Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master 28055a62 02/11: Realize the actual intention of a comparison, Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master a3278e2b 10/11: Expunge 'stl_extensions.hpp', Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master c6dc35ea 05/11: Demonstrate equivalence of bin_exp() to SGI's power(), Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master 8922e7a1 06/11: Explain restrictions on bin_exp() argument types, Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master 8cbc3001 07/11: Make a value definitely exact and definitely constexpr, Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master 2c8cc917 04/11: Don't bother calculating 2^64 - 1,
Greg Chicares <=
- [lmi-commits] [lmi] master 7727d36d 08/11: Prefer bin_exp() to SGI's power(), Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master d9655b77 01/11: Refactor: rename local variables, Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master 2576d70c 09/11: Prefer bin_exp() to SGI's power(), Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master fd325f5e 11/11: Record speed measurements, Greg Chicares, 2022/05/31