[geos-commits] [SCM] GEOS branch svn-3.6 updated. 9362bf25c5ab5508aa70287a6c557ea5d0596beb

git at osgeo.org git at osgeo.org
Wed Sep 18 08:47:34 PDT 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, svn-3.6 has been updated
       via  9362bf25c5ab5508aa70287a6c557ea5d0596beb (commit)
      from  f1868e13354fb72cd14b4649e1ee9124ce079e62 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9362bf25c5ab5508aa70287a6c557ea5d0596beb
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Sep 18 08:47:24 2019 -0700

    Improve the bit-shifting logic with good types and so on
    Even Roualt, Kurt Schwehr
    References #869

diff --git a/src/precision/CommonBits.cpp b/src/precision/CommonBits.cpp
index a1cd754..763b33b 100644
--- a/src/precision/CommonBits.cpp
+++ b/src/precision/CommonBits.cpp
@@ -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)

-----------------------------------------------------------------------

Summary of changes:
 src/precision/CommonBits.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list