GEOS  3.14.0dev
CommonBits.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2005-2006 Refractions Research Inc.
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************/
14 
15 #pragma once
16 
17 #include <geos/export.h>
18 #include <cstdint>
19 
20 namespace geos {
21 namespace precision { // geos.precision
22 
32 class GEOS_DLL CommonBits {
33 
34 private:
35 
36  bool isFirst;
37 
38  int commonMantissaBitsCount;
39 
40  int64_t commonBits;
41 
42  int64_t commonSignExp;
43 
44 public:
45 
53  static int64_t signExpBits(int64_t num);
54 
67  static int numCommonMostSigMantissaBits(int64_t num1, int64_t num2);
68 
76  static int64_t zeroLowerBits(int64_t bits, int nBits);
77 
85  static int getBit(int64_t bits, int i);
86 
87  CommonBits();
88 
89  void add(double num);
90 
91  double getCommon();
92 
93 };
94 
95 } // namespace geos.precision
96 } // namespace geos
97 
Determines the maximum number of common most-significant bits in the mantissa of one or numbers.
Definition: CommonBits.h:32
static int64_t zeroLowerBits(int64_t bits, int nBits)
Zeroes the lower n bits of a bitstring.
static int getBit(int64_t bits, int i)
Extracts the i'th bit of a bitstring.
static int64_t signExpBits(int64_t num)
Computes the bit pattern for the sign and exponent of a double-precision number.
static int numCommonMostSigMantissaBits(int64_t num1, int64_t num2)
This computes the number of common most-significant bits in the mantissas of two double-precision num...
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25