fn round(&mut self, mut sbit: usize) {
        self.acc = Accuracy::Exact;
        
        if !self.form.is_finite() {
            return;
        }
        
        let m = self.mant.as_vec().len();
        let bits = m << 5;
        if bits <= self.prec {
            // mantissa fits => nothing to do
            return;
        }

        // Rounding is based on two bits: the rounding bit (rbit) and the
        // sticky bit (sbit). The rbit is the bit immediately before the
        // z.prec leading mantissa bits (the "0.5"). The sbit is set if any
        // of the bits before the rbit are set (the "0.25", "0.125", etc.):
        //
        //   rbit  sbit  => "fractional part"
        //
        //   0     0        == 0
        //   0     1        >  0  , < 0.5
        //   1     0        == 0.5
        //   1     1        >  0.5, < 1.0

        // bits > z.prec: mantissa too large => round
        let r = bits - self.prec - 1; // rounding bit position; r >= 0
        // rounding bit; be safe and ensure it's a single bit
        let rbit = match self.mant.is_set_bit(r) {
            Some(true) => 1,
            _ => 0,
        };
        // The sticky bit is only needed for rounding ToNearestEven
        // or when the rounding bit is zero. Avoid computation otherwise.
        if sbit == 0 && (rbit == 0 || self.mode == ToNearestEven) {
            sbit = self.mant.sticky(r);
        }
        sbit &= 1; // be safe and ensure it's a single bit

        // cut off extra words
        let n = (self.prec + 31) >> 5; // mantissa length in words for desired precision
        if m > n {
            self.mant.as_mut_vec().rotate_left(m-n); // move n last words to front
            self.mant.as_mut_vec().truncate(n);
        }

        // determine number of trailing zero bits (ntz) and compute lsb mask of mantissa's least-significant word
        let ntz = (n<<5) - self.prec;
        let lsb = 1 << ntz;

        // round if result is inexact
        if (rbit | sbit) != 0 {
            // Make rounding decision: The result mantissa is truncated ("rounded down")
            // by default. Decide if we need to increment, or "round up", the (unsigned)
            // mantissa.
            let mut inc = false;
            inc = match self.mode {
                ToNegativeInf => self.neg == Negative,
                ToZero => inc,
                ToNearestEven => rbit != 0 && (sbit != 0 || (self.mant.as_vec()[0] & lsb) != 0),
                ToNearestAway => rbit != 0,
                AwayFromZero => true,
                ToPositiveInf => self.neg != Negative,
            };

            // A positive result (!z.neg) is Above the exact result if we increment,
            // and it's Below if we truncate (Exact results require no rounding).
            // For a negative result (z.neg) it is exactly the opposite.
            self.acc = Self::make_accuracy(BISign::from(inc) != self.neg);

            unsafe {
                if inc {
                    // add 1 to mantissa
                    if add_vw_inner(self.mant.as_mut_vec().as_mut_ptr(), self.mant.as_vec().as_ptr(), lsb, self.mant.as_vec().len()) != 0 {
                        // mantissa overflow => adjust exponent
                        if self.exp >= Self::max_exp() {
                            // exponent overflow
                            self.form = Form::Inf;
                            return;
                        } else {
                            self.exp += 1;
                            // adjust mantissa: divide by 2 to compensate for exponent adjustment
                            shr_vu_inner(self.mant.as_mut_vec().as_mut_ptr(), self.mant.as_vec().as_ptr(), 1, self.mant.as_vec().len());
                            // set msb == carry == 1 from the mantissa overflow above
                            self.mant.as_mut_vec()[n-1] |= 1 << 31;
                        }
                    }
                }
            }
        }

        // zero out trailing bits in least-significant word
        self.mant.as_mut_vec()[0] &= !(lsb - 1);
    }
/// round rounds z according to z.mode to z.prec bits and sets z.acc accordingly.
/// sbit must be 0 or 1 and summarizes any "sticky bit" information one might
/// have before calling round. z's mantissa must be normalized (with the msb set)
/// or empty.
///
/// CAUTION: The rounding modes ToNegativeInf, ToPositiveInf are affected by the
/// sign of z. For correct rounding, the sign of z must be set correctly before
/// calling round.


The rounding modes ToNegativeInf, ToPositiveInf are affected by the
sign of z. For correct rounding, the sign of z must be set correctly before
calling round.
The rounding modes ToNegativeInf ToPositiveInf are affected by the sign of z . For correct rounding the sign of z must be set correctly before calling round .
fn round(&mut self, mut sbit: usize) {
        self.acc = Accuracy::Exact;
        if !self.form.is_finite() {
            return;
        }
        let m = self.mant.as_vec().len();
        let bits = m << 5;
        if bits <= self.prec {
            // mantissa fits => nothing to do
            return;
        }
        // Rounding is based on two bits: the rounding bit (rbit) and the
        // sticky bit (sbit). The rbit is the bit immediately before the
        // z.prec leading mantissa bits (the "0.5"). The sbit is set if any
        // of the bits before the rbit are set (the "0.25", "0.125", etc.):
        //
        //   rbit  sbit  => "fractional part"
        //
        //   0     0        == 0
        //   0     1        >  0  , < 0.5
        //   1     0        == 0.5
        //   1     1        >  0.5, < 1.0
        // bits > z.prec: mantissa too large => round
        let r = bits - self.prec - 1; // rounding bit position; r >= 0
        // rounding bit; be safe and ensure it's a single bit
        let rbit = match self.mant.is_set_bit(r) {
            Some(true) => 1,
            _ => 0,
        };
        // The sticky bit is only needed for rounding ToNearestEven
        // or when the rounding bit is zero. Avoid computation otherwise.
        if sbit == 0 && (rbit == 0 || self.mode == ToNearestEven) {
            sbit = self.mant.sticky(r);
        }
        sbit &= 1; // be safe and ensure it's a single bit
        // cut off extra words
        let n = (self.prec + 31) >> 5; // mantissa length in words for desired precision
        if m > n {
            self.mant.as_mut_vec().rotate_left(m-n); // move n last words to front
            self.mant.as_mut_vec().truncate(n);
        }
        // determine number of trailing zero bits (ntz) and compute lsb mask of mantissa's least-significant word
        let ntz = (n<<5) - self.prec;
        let lsb = 1 << ntz;
        // round if result is inexact
        if (rbit | sbit) != 0 {
            // Make rounding decision: The result mantissa is truncated ("rounded down")
            // by default. Decide if we need to increment, or "round up", the (unsigned)
            // mantissa.
            let mut inc = false;
            inc = match self.mode {
                ToNegativeInf => self.neg == Negative,
                ToZero => inc,
                ToNearestEven => rbit != 0 && (sbit != 0 || (self.mant.as_vec()[0] & lsb) != 0),
                ToNearestAway => rbit != 0,
                AwayFromZero => true,
                ToPositiveInf => self.neg != Negative,
            };
            // A positive result (!z.neg) is Above the exact result if we increment,
            // and it's Below if we truncate (Exact results require no rounding).
            // For a negative result (z.neg) it is exactly the opposite.
            self.acc = Self::make_accuracy(BISign::from(inc) != self.neg);
            unsafe {
                if inc {
                    // add 1 to mantissa
                    if add_vw_inner(self.mant.as_mut_vec().as_mut_ptr(), self.mant.as_vec().as_ptr(), lsb, self.mant.as_vec().len()) != 0 {
                        // mantissa overflow => adjust exponent
                        if self.exp >= Self::max_exp() {
                            // exponent overflow
                            self.form = Form::Inf;
                            return;
                        } else {
                            self.exp += 1;
                            // adjust mantissa: divide by 2 to compensate for exponent adjustment
                            shr_vu_inner(self.mant.as_mut_vec().as_mut_ptr(), self.mant.as_vec().as_ptr(), 1, self.mant.as_vec().len());
                            // set msb == carry == 1 from the mantissa overflow above
                            self.mant.as_mut_vec()[n-1] |= 1 << 31;
                        }
                    }
                }
            }
        }
        // zero out trailing bits in least-significant word
        self.mant.as_mut_vec()[0] &= !(lsb - 1);
    }
fn round ( & mut self , mut sbit : usize ) { self . acc = Accuracy :: Exact ; if ! self . form . is_finite ( ) { return ; } let m = self . mant . as_vec ( ) . len ( ) ; let bits = m << 5 ; if bits <= self . prec { // mantissa fits => nothing to do return ; } // Rounding is based on two bits: the rounding bit (rbit) and the // sticky bit (sbit). The rbit is the bit immediately before the // z.prec leading mantissa bits (the "0.5"). The sbit is set if any // of the bits before the rbit are set (the "0.25", "0.125", etc.): // //   rbit  sbit  => "fractional part" // //   0     0        == 0 //   0     1        >  0  , < 0.5 //   1     0        == 0.5 //   1     1        >  0.5, < 1.0 // bits > z.prec: mantissa too large => round let r = bits - self . prec - 1 ; // rounding bit position; r >= 0 // rounding bit; be safe and ensure it's a single bit let rbit = match self . mant . is_set_bit ( r ) { Some ( true ) => 1 , _ => 0 , } ; // The sticky bit is only needed for rounding ToNearestEven // or when the rounding bit is zero. Avoid computation otherwise. if sbit == 0 && ( rbit == 0 || self . mode == ToNearestEven ) { sbit = self . mant . sticky ( r ) ; } sbit &= 1 ; // be safe and ensure it's a single bit // cut off extra words let n = ( self . prec + 31 ) >> 5 ; // mantissa length in words for desired precision if m > n { self . mant . as_mut_vec ( ) . rotate_left ( m - n ) ; // move n last words to front self . mant . as_mut_vec ( ) . truncate ( n ) ; } // determine number of trailing zero bits (ntz) and compute lsb mask of mantissa's least-significant word let ntz = ( n << 5 ) - self . prec ; let lsb = 1 << ntz ; // round if result is inexact if ( rbit | sbit ) != 0 { // Make rounding decision: The result mantissa is truncated ("rounded down") // by default. Decide if we need to increment, or "round up", the (unsigned) // mantissa. let mut inc = false ; inc = match self . mode { ToNegativeInf => self . neg == Negative , ToZero => inc , ToNearestEven => rbit != 0 && ( sbit != 0 || ( self . mant . as_vec ( ) [ 0 ] & lsb ) != 0 ) , ToNearestAway => rbit != 0 , AwayFromZero => true , ToPositiveInf => self . neg != Negative , } ; // A positive result (!z.neg) is Above the exact result if we increment, // and it's Below if we truncate (Exact results require no rounding). // For a negative result (z.neg) it is exactly the opposite. self . acc = Self :: make_accuracy ( BISign :: from ( inc ) != self . neg ) ; unsafe { if inc { // add 1 to mantissa if add_vw_inner ( self . mant . as_mut_vec ( ) . as_mut_ptr ( ) , self . mant . as_vec ( ) . as_ptr ( ) , lsb , self . mant . as_vec ( ) . len ( ) ) != 0 { // mantissa overflow => adjust exponent if self . exp >= Self :: max_exp ( ) { // exponent overflow self . form = Form :: Inf ; return ; } else { self . exp += 1 ; // adjust mantissa: divide by 2 to compensate for exponent adjustment shr_vu_inner ( self . mant . as_mut_vec ( ) . as_mut_ptr ( ) , self . mant . as_vec ( ) . as_ptr ( ) , 1 , self . mant . as_vec ( ) . len ( ) ) ; // set msb == carry == 1 from the mantissa overflow above self . mant . as_mut_vec ( ) [ n - 1 ] |= 1 << 31 ; } } } } } // zero out trailing bits in least-significant word self . mant . as_mut_vec ( ) [ 0 ] &= ! ( lsb - 1 ) ; }
round rounds z according to z.mode to z.prec bits and sets z.acc accordingly.
round rounds z according to z . mode to z . prec bits and sets z . acc accordingly .
&mut self
sbit
usize
&mut self
sbit
usize