DoubleBits.h

00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2006 Refractions Research Inc.
00007  *
00008  * This is free software; you can redistribute and/or modify it under
00009  * the terms of the GNU Lesser General Public Licence as published
00010  * by the Free Software Foundation. 
00011  * See the COPYING file for more information.
00012  *
00013  **********************************************************************
00014  *
00015  * Last port: index/quadtree/DoubleBits.java rev. 1.7 (JTS-1.10)
00016  *
00017  **********************************************************************/
00018 
00019 #ifndef GEOS_IDX_QUADTREE_DOUBLEBITS_H
00020 #define GEOS_IDX_QUADTREE_DOUBLEBITS_H
00021 
00022 #include <geos/export.h>
00023 #include <geos/platform.h> // for int64
00024 
00025 #include <string>
00026 
00027 namespace geos {
00028 namespace index { // geos::index
00029 namespace quadtree { // geos::index::quadtree
00030 
00031 
00044 class GEOS_DLL 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 } // namespace geos::index::quadtree
00099 } // namespace geos::index
00100 } // namespace geos
00101 
00102 #endif // GEOS_IDX_QUADTREE_DOUBLEBITS_H

Generated on 15 May 2014 for GEOS by  doxygen 1.4.7