00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEOS_IDX_QUADTREE_DOUBLEBITS_H
00021 #define GEOS_IDX_QUADTREE_DOUBLEBITS_H
00022
00023 #include <geos/platform.h>
00024
00025 #include <string>
00026
00027 namespace geos {
00028 namespace index {
00029 namespace quadtree {
00030
00031
00044 class DoubleBits {
00045
00046 public:
00047
00048 static const int EXPONENT_BIAS=1023;
00049
00050 static double powerOf2(int exp);
00051
00052 static int exponent(double d);
00053
00054 static double truncateToPowerOfTwo(double d);
00055
00056 static std::string toBinaryString(double d);
00057
00058 static double maximumCommonMantissa(double d1, double d2);
00059
00060 DoubleBits(double nx);
00061
00062 double getDouble() const;
00063
00065 int64 biasedExponent() const;
00066
00068 int getExponent() const;
00069
00070 void zeroLowerBits(int nBits);
00071
00072 int getBit(int i) const;
00073
00086 int numCommonMantissaBits(const DoubleBits& db) const;
00087
00089 std::string toString() const;
00090
00091 private:
00092
00093 double x;
00094
00095 int64 xBits;
00096 };
00097
00098 }
00099 }
00100 }
00101
00102 #endif // GEOS_IDX_QUADTREE_DOUBLEBITS_H
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113