GEOS  3.8.0dev
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
geos::index::quadtree::DoubleBits Class Reference

DoubleBits manipulates Double numbers by using bit manipulation and bit-field extraction. More...

#include <DoubleBits.h>

Public Member Functions

 DoubleBits (double nx)
 
double getDouble () const
 
int64 biasedExponent () const
 Determines the exponent for the number.
 
int getExponent () const
 Determines the exponent for the number.
 
void zeroLowerBits (int nBits)
 
int getBit (int i) const
 
int numCommonMantissaBits (const DoubleBits &db) const
 This computes the number of common most-significant bits in the mantissa. More...
 
std::string toString () const
 A representation of the Double bits formatted for easy readability.
 

Static Public Member Functions

static double powerOf2 (int exp)
 
static int exponent (double d)
 
static double truncateToPowerOfTwo (double d)
 
static std::string toBinaryString (double d)
 
static double maximumCommonMantissa (double d1, double d2)
 

Static Public Attributes

static const int EXPONENT_BIAS = 1023
 

Detailed Description

DoubleBits manipulates Double numbers by using bit manipulation and bit-field extraction.

For some operations (such as determining the exponent) this is more accurate than using mathematical operations (which suffer from round-off error).

The algorithms and constants in this class apply only to IEEE-754 double-precision floating point format.

Member Function Documentation

int geos::index::quadtree::DoubleBits::numCommonMantissaBits ( const DoubleBits db) const

This computes the number of common most-significant bits in the mantissa.

It does not count the hidden bit, which is always 1. It does not determine whether the numbers have the same exponent; if they do not, the value computed by this function is meaningless.

Parameters
db
Returns
the number of common most-significant mantissa bits

The documentation for this class was generated from the following file: