Commit 9362bf25 authored by Paul Ramsey's avatar Paul Ramsey

Improve the bit-shifting logic with good types and so on

Even Roualt, Kurt Schwehr
References #869
parent f1868e13
Pipeline #82996628 failed with stage
in 5 minutes and 7 seconds
......@@ -8,7 +8,7 @@
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
......@@ -43,13 +43,13 @@ CommonBits::numCommonMostSigMantissaBits(int64 num1, int64 num2)
int64
CommonBits::zeroLowerBits(int64 bits, int nBits)
{
if (nBits >= 64) return 0;
int64 invMask = (1<< nBits)-1;
int64 mask = ~ invMask;
int64 zeroed = bits & mask;
return zeroed;
if (nBits >= 64 || nBits < 1) return 0;
const uint64_t bits_ = static_cast<uint64_t>(bits);
const uint64_t invMask = (1ull << nBits) - 1;
const uint64_t mask = ~ invMask;
const uint64_t zeroed = bits_ & mask;
return static_cast<int64>(zeroed);
}
/*static public*/
int
CommonBits::getBit(int64 bits, int i)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment