Class CommonBits


  • public class CommonBits
    extends java.lang.Object
    Determines the maximum number of common most-significant bits in the mantissa of one or numbers. Can be used to compute the double-precision number which is represented by the common bits. If there are no common bits, the number computed is 0.0.
    Version:
    1.7
    • Constructor Summary

      Constructors 
      Constructor Description
      CommonBits()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(double num)  
      static int getBit​(long bits, int i)
      Extracts the i'th bit of a bitstring.
      double getCommon()  
      static int numCommonMostSigMantissaBits​(long num1, long num2)
      This computes the number of common most-significant bits in the mantissas of two double-precision numbers.
      static long signExpBits​(long num)
      Computes the bit pattern for the sign and exponent of a double-precision number.
      java.lang.String toString​(long bits)
      A representation of the Double bits formatted for easy readability
      static long zeroLowerBits​(long bits, int nBits)
      Zeroes the lower n bits of a bitstring.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CommonBits

        public CommonBits()
    • Method Detail

      • signExpBits

        public static long signExpBits​(long num)
        Computes the bit pattern for the sign and exponent of a double-precision number.
        Parameters:
        num -
        Returns:
        the bit pattern for the sign and exponent
      • numCommonMostSigMantissaBits

        public static int numCommonMostSigMantissaBits​(long num1,
                                                       long num2)
        This computes the number of common most-significant bits in the mantissas of two double-precision numbers. 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:
        num1 - the first number
        num2 - the second number
        Returns:
        the number of common most-significant mantissa bits
      • zeroLowerBits

        public static long zeroLowerBits​(long bits,
                                         int nBits)
        Zeroes the lower n bits of a bitstring.
        Parameters:
        bits - the bitstring to alter
        Returns:
        the zeroed bitstring
      • getBit

        public static int getBit​(long bits,
                                 int i)
        Extracts the i'th bit of a bitstring.
        Parameters:
        bits - the bitstring to extract from
        i - the bit to extract
        Returns:
        the value of the extracted bit
      • add

        public void add​(double num)
      • getCommon

        public double getCommon()
      • toString

        public java.lang.String toString​(long bits)
        A representation of the Double bits formatted for easy readability