Class DoubleBits

Hierarchy: Object , DoubleBits
public class DoubleBits
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.

Other

  • version: 1.7
public DoubleBits(double x)
public static double powerOf2(int exp)
public static int exponent(double d)
public static double truncateToPowerOfTwo(double d)
public static String toBinaryString(double d)
public static double maximumCommonMantissa(double d1, double d2)
public double getDouble()
public int biasedExponent()
Determines the exponent for the number
public int getExponent()
Determines the exponent for the number
public void zeroLowerBits(int nBits)
public int getBit(int i)
public int numCommonMantissaBits(DoubleBits db)
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 - db
Returns:
the number of common most-significant mantissa bits
public String toString()
A representation of the Double bits formatted for easy readability