// Returns the two boundaries of first argument. // The bigger boundary (m_plus) is normalized. The lower boundary has the same // exponent as m_plus. internal static void NormalizedBoundaries(long d64, DiyFp mMinus, DiyFp mPlus) { DiyFp v = AsDiyFp(d64); bool significandIsZero = (v.F == KHiddenBit); mPlus.F = (v.F << 1) + 1; mPlus.E = v.E - 1; mPlus.Normalize(); if (significandIsZero && 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. mMinus.F = (v.F << 2) - 1; mMinus.E = v.E - 2; } else { mMinus.F = (v.F << 1) - 1; mMinus.E = v.E - 1; } mMinus.F = mMinus.F << (mMinus.E - mPlus.E); mMinus.E = mPlus.E; }
// Returns the two boundaries of first argument. // The bigger boundary (m_plus) is normalized. The lower boundary has the same // exponent as m_plus. internal static NormalizedBoundariesResult NormalizedBoundaries(long d64) { DiyFp v = AsDiyFp(d64); bool significandIsZero = (v.F == KHiddenBit); var mPlus = DiyFp.Normalize((v.F << 1) + 1, v.E - 1); DiyFp mMinus; if (significandIsZero && 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. mMinus = new DiyFp((v.F << 2) - 1, v.E - 2); } else { mMinus = new DiyFp((v.F << 1) - 1, v.E - 1); } mMinus = new DiyFp(mMinus.F << (mMinus.E - mPlus.E), mPlus.E); return new NormalizedBoundariesResult(mMinus, mPlus); }
// Returns the two boundaries of first argument. // The bigger boundary (m_plus) is normalized. The lower boundary has the same // exponent as m_plus. internal static void NormalizedBoundaries(long d64, DiyFp mMinus, DiyFp mPlus) { DiyFp v = AsDiyFp(d64); bool significandIsZero = (v.F == KHiddenBit); mPlus.F = (v.F << 1) + 1; mPlus.E = v.E - 1; mPlus.Normalize(); if (significandIsZero && 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. mMinus.F = (v.F << 2) - 1; mMinus.E = v.E - 2; } else { mMinus.F = (v.F << 1) - 1; mMinus.E = v.E - 1; } mMinus.F = mMinus.F << (mMinus.E - mPlus.E); mMinus.E = mPlus.E; }