GEOS  3.10.1
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 #ifndef GEOS_PRECISION_COMMONBITS_H
16 #define GEOS_PRECISION_COMMONBITS_H
17 
18 #include <geos/export.h>
19 #include <cstdint>
20 
21 namespace geos {
22 namespace precision { // geos.precision
23 
33 class GEOS_DLL CommonBits {
34 
35 private:
36 
37  bool isFirst;
38 
39  int commonMantissaBitsCount;
40 
41  int64_t commonBits;
42 
43  int64_t commonSignExp;
44 
45 public:
46 
54  static int64_t signExpBits(int64_t num);
55 
68  static int numCommonMostSigMantissaBits(int64_t num1, int64_t num2);
69 
77  static int64_t zeroLowerBits(int64_t bits, int nBits);
78 
86  static int getBit(int64_t bits, int i);
87 
88  CommonBits();
89 
90  void add(double num);
91 
92  double getCommon();
93 
94 };
95 
96 } // namespace geos.precision
97 } // namespace geos
98 
99 #endif // GEOS_PRECISION_COMMONBITS_H
Determines the maximum number of common most-significant bits in the mantissa of one or numbers.
Definition: CommonBits.h:33
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:26