GEOS: DoubleBits.h Source File

GEOS 3.5.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

DoubleBits.h
1 /**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 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 * Last port: index/quadtree/DoubleBits.java rev. 1.7 (JTS-1.10)
16 *
17 **********************************************************************/
18
19 #ifndef GEOS_IDX_QUADTREE_DOUBLEBITS_H
20 #define GEOS_IDX_QUADTREE_DOUBLEBITS_H
21
22 #include <geos/export.h>
23 #include <geos/platform.h> // for int64
24
25 #include <string>
26
27 namespace geos {
28 namespace index { // geos::index
29 namespace quadtree { // geos::index::quadtree
30
31
44 class GEOS_DLL DoubleBits {
45
46 public:
47
48 static const int EXPONENT_BIAS=1023;
49
50 static double powerOf2(int exp);
51
52 static int exponent(double d);
53
54 static double truncateToPowerOfTwo(double d);
55
56 static std::string toBinaryString(double d);
57
58 static double maximumCommonMantissa(double d1, double d2);
59
60 DoubleBits(double nx);
61
62 double getDouble() const;
63
65 int64 biasedExponent() const;
66
68 int getExponent() const;
69
70 void zeroLowerBits(int nBits);
71
72 int getBit(int i) const;
73
86 int numCommonMantissaBits(const DoubleBits& db) const;
87
89 std::string toString() const;
90
91 private:
92
93 double x;
94
95 int64 xBits;
96 };
97
98 } // namespace geos::index::quadtree
99 } // namespace geos::index
100 } // namespace geos
101
102 #endif // GEOS_IDX_QUADTREE_DOUBLEBITS_H
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::index::quadtree::DoubleBits
DoubleBits manipulates Double numbers by using bit manipulation and bit-field extraction.
Definition: DoubleBits.h:44