Exemple #1
0
        public static DiyFp Normalize(ref DiyFp a)
        {
            DiyFp result = a;

            result.Normalize();
            return(result);
        }
Exemple #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)
        {
            Debug.Assert(Value > 0.0);
            DiyFp v      = AsDiyFp;
            DiyFp m_plus = new DiyFp((v.F << 1) + 1, v.E - 1);

            m_plus.Normalize();
            DiyFp m_minus = LowerBoundaryIsCloser() ?
                            new DiyFp((v.F << 2) - 1, v.E - 2) :
                            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;
        }
Exemple #3
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)
 {
     Debug.Assert(Value > 0.0);
     DiyFp v = AsDiyFp;
     DiyFp m_plus = new DiyFp((v.F << 1) + 1, v.E - 1);
     m_plus.Normalize();
     DiyFp m_minus = LowerBoundaryIsCloser() ?
         new DiyFp((v.F << 2) - 1, v.E - 2) :
         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;
 }