// Returns the two boundaries of first argument. // The bigger boundary (m_plus) is normalized. The lower boundary has the same // exponent as m_plus. static void normalizedBoundaries(long d64, DiyFp m_minus, DiyFp m_plus) { DiyFp v = asDiyFp(d64); boolean significand_is_zero = (v.f() == kHiddenBit); m_plus.setF((v.f() << 1) + 1); m_plus.setE(v.e() - 1); m_plus.normalize(); if (significand_is_zero && v.e() != kDenormalExponent) { // The boundary is closer. Think of v = 1000e10 and v- = 9999e9. // Then the boundary (== (v - v-)/2) is not just at a distance of 1e9 but // at a distance of 1e8. // The only exception is for the smallest normal: the largest denormal is // at the same distance as its successor. // Note: denormals have the same exponent as the smallest normals. m_minus.setF((v.f() << 2) - 1); m_minus.setE(v.e() - 2); } else { m_minus.setF((v.f() << 1) - 1); m_minus.setE(v.e() - 1); } m_minus.setF(m_minus.f() << (m_minus.e() - m_plus.e())); m_minus.setE(m_plus.e()); }