numCommonMantissaBits method

int numCommonMantissaBits(
  1. 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. @param db @return the number of common most-significant mantissa bits

Implementation

int numCommonMantissaBits(DoubleBits db) {
  for (int i = 0; i < 52; i++) {
    if (getBit(i) != db.getBit(i)) return i;
  }
  return 52;
}