DoubleBits.h

00001 /**********************************************************************
00002  * $Id: DoubleBits.h 1820 2006-09-06 16:54:23Z mloskot $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2006 Refractions Research Inc.
00008  *
00009  * This is free software; you can redistribute and/or modify it under
00010  * the terms of the GNU Lesser General Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  **********************************************************************
00015  *
00016  * Last port: index/quadtree/DoubleBits.java rev. 1.7 (JTS-1.7.1)
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef GEOS_IDX_QUADTREE_DOUBLEBITS_H
00021 #define GEOS_IDX_QUADTREE_DOUBLEBITS_H
00022 
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 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
00103 
00104 /**********************************************************************
00105  * $Log$
00106  * Revision 1.2  2006/05/23 14:29:33  strk
00107  * * source/headers/geos/index/quadtree/DoubleBits.h, source/index/quadtree/DoubleBits.cpp: const correctness and documentation.
00108  *
00109  * Revision 1.1  2006/03/22 12:22:50  strk
00110  * indexQuadtree.h split
00111  *
00112  **********************************************************************/
00113 

Generated on Fri Mar 27 04:52:39 2009 for GEOS by  doxygen 1.5.4