Пример #1
0
        public static DiyFp Normalize(ref DiyFp a)
        {
            DiyFp result = a;

            result.Normalize();
            return(result);
        }
Пример #2
0
        // Computes the two boundaries of this.
        // The bigger boundary (m_plus) is normalized. The lower boundary has the same
        // exponent as m_plus.
        // Precondition: the value encoded by this Single must be greater than 0.
        public void NormalizedBoundaries(out DiyFp out_m_minus, out DiyFp out_m_plus)
        {
            DiyFp v      = this.AsDiyFp();
            var   __     = new DiyFp((v.f << 1) + 1, v.e - 1);
            DiyFp m_plus = DiyFp.Normalize(ref __);
            DiyFp m_minus;

            if (LowerBoundaryIsCloser())
            {
                m_minus = new DiyFp((v.f << 2) - 1, v.e - 2);
            }
            else
            {
                m_minus = new DiyFp((v.f << 1) - 1, v.e - 1);
            }
            m_minus.f   = (m_minus.f << (m_minus.e - m_plus.e));
            m_minus.e   = (m_plus.e);
            out_m_plus  = m_plus;
            out_m_minus = m_minus;
        }