fn quo_to_f32(a: Nat, b: Nat) -> (f32, bool) {
        debug_assert!(!a.is_nan() && !b.is_nan());
        debug_assert_ne!(b, 0u32);
        
        let (fsize, msize) = (32, 23);
        let (msize1, msize2) = (msize + 1, msize + 2);
        let esize = fsize - msize1;
        let ebias = (1 << (esize - 1)) - 1;
        let (emin, _emax) = (1 - ebias, ebias);
        
        if a == 0u32 {
            (0f32, true);
        }
        
        let (alen, blen) = (a.bits_len() as isize, b.bits_len() as isize);

        // 1. Left-shift A or B such that quotient A/B is in [1<<Msize1, 1<<(Msize2+1)
        // (Msize2 bits if A < B when they are left-aligned, Msize2+1 bits if A >= B).
        // This is 2 or 3 more than the float32 mantissa field width of Msize:
        // - the optional extra bit is shifted away in step 3 below.
        // - the high-order 1 is omitted in "normal" representation;
        // - the low-order 1 will be used during rounding then discarded.
        let mut exp = alen - blen;
        let (shift, is_great) = if msize2 > exp {((msize2 - exp) as usize, true)} else {((exp - msize2) as usize, false)};
        let (mut a2, mut b2) = (a.deep_clone(), b.deep_clone());
        if is_great {a2.shl_inner(&shift);} else {b2.shl_inner(&shift);}

        // 2. Compute quotient and remainder (q, r).  NB: due to the
        // extra shift, the low-order bit of q is logically the
        // high-order bit of r.
        // mantissa&1 && !haveRem => remainder is exactly half
        let (q, r) = (a2.clone() / b2.clone(), a2.clone() % b2.clone());
        let (mut mantissa, mut is_have_rem) = (q.as_vec()[0], r > 0u32); // mantissa&1 && !haveRem => remainder is exactly half

        // 3. If quotient didn't fit in Msize2 bits, redo division by b2<<1
        // (in effect---we accomplish this incrementally).
        if (mantissa >> msize2) == 1 {
            if mantissa & 1 == 1 {
                is_have_rem = true;
            }
            mantissa >>= 1;
            exp += 1;
        }
        
        if (mantissa >> msize1) != 1 {
            panic!("the numerator of {:#x} and the denominator of {:#x} have the common factor that great than 1", a, b);
        }
        
        // 4. Rounding.
        if (emin - msize) <= exp && exp <= emin {
            // Denormal case; lose 'shift' bits of precision.
            let shift = (emin - (exp - 1)) as usize; // [1..Esize1)
            let lostbits = mantissa & ((1 << shift) - 1);
            is_have_rem = is_have_rem || lostbits != 0;
            mantissa >>= shift;
            exp = 2 - ebias; // == exp + shift
        }
        
        // Round q using round-half-to-even.
        let mut exact = !is_have_rem;
        if (mantissa & 1) != 0 {
            exact = false;
            if is_have_rem || (mantissa & 2) != 0 {
                mantissa += 1;
                if mantissa >= (1 << msize2) {
                    // Complete rollover 11...1 => 100...0, so shift is safe
                    mantissa >>= 1;
                    exp += 1;
                }
            }
        }
        mantissa >>= 1; // discard rounding bit.  Mantissa now scaled by 1<<Msize1.

        let f = util::ldexp(mantissa as f64, exp - msize1) as f32;
        if f.is_infinite() {
            (f, false)
        } else {
            (f, exact)
        }
    }
/// quotToFloat32 returns the non-negative float32 value  
/// nearest to the quotient a/b, using round-to-even in  
/// halfway cases. It does not mutate its arguments.  
/// Preconditions: b is non-zero; a and b have no common factors.  
quotToFloat32 returns the non-negative float32 value
nearest to the quotient a/b, using round-to-even in
halfway cases. It does not mutate its arguments.
Preconditions: b is non-zero; a and b have no common factors.
quotToFloat32 returns the non - negative float32 value nearest to the quotient a / b using round - to - even in halfway cases . It does not mutate its arguments . Preconditions : b is non - zero ; a and b have no common factors .
fn quo_to_f32(a: Nat, b: Nat) -> (f32, bool) {
        debug_assert!(!a.is_nan() && !b.is_nan());
        debug_assert_ne!(b, 0u32);
        let (fsize, msize) = (32, 23);
        let (msize1, msize2) = (msize + 1, msize + 2);
        let esize = fsize - msize1;
        let ebias = (1 << (esize - 1)) - 1;
        let (emin, _emax) = (1 - ebias, ebias);
        if a == 0u32 {
            (0f32, true);
        }
        let (alen, blen) = (a.bits_len() as isize, b.bits_len() as isize);
        // 1. Left-shift A or B such that quotient A/B is in [1<<Msize1, 1<<(Msize2+1)
        // (Msize2 bits if A < B when they are left-aligned, Msize2+1 bits if A >= B).
        // This is 2 or 3 more than the float32 mantissa field width of Msize:
        // - the optional extra bit is shifted away in step 3 below.
        // - the high-order 1 is omitted in "normal" representation;
        // - the low-order 1 will be used during rounding then discarded.
        let mut exp = alen - blen;
        let (shift, is_great) = if msize2 > exp {((msize2 - exp) as usize, true)} else {((exp - msize2) as usize, false)};
        let (mut a2, mut b2) = (a.deep_clone(), b.deep_clone());
        if is_great {a2.shl_inner(&shift);} else {b2.shl_inner(&shift);}
        // 2. Compute quotient and remainder (q, r).  NB: due to the
        // extra shift, the low-order bit of q is logically the
        // high-order bit of r.
        // mantissa&1 && !haveRem => remainder is exactly half
        let (q, r) = (a2.clone() / b2.clone(), a2.clone() % b2.clone());
        let (mut mantissa, mut is_have_rem) = (q.as_vec()[0], r > 0u32); // mantissa&1 && !haveRem => remainder is exactly half
        // 3. If quotient didn't fit in Msize2 bits, redo division by b2<<1
        // (in effect---we accomplish this incrementally).
        if (mantissa >> msize2) == 1 {
            if mantissa & 1 == 1 {
                is_have_rem = true;
            }
            mantissa >>= 1;
            exp += 1;
        }
        if (mantissa >> msize1) != 1 {
            panic!("the numerator of {:#x} and the denominator of {:#x} have the common factor that great than 1", a, b);
        }
        // 4. Rounding.
        if (emin - msize) <= exp && exp <= emin {
            // Denormal case; lose 'shift' bits of precision.
            let shift = (emin - (exp - 1)) as usize; // [1..Esize1)
            let lostbits = mantissa & ((1 << shift) - 1);
            is_have_rem = is_have_rem || lostbits != 0;
            mantissa >>= shift;
            exp = 2 - ebias; // == exp + shift
        }
        // Round q using round-half-to-even.
        let mut exact = !is_have_rem;
        if (mantissa & 1) != 0 {
            exact = false;
            if is_have_rem || (mantissa & 2) != 0 {
                mantissa += 1;
                if mantissa >= (1 << msize2) {
                    // Complete rollover 11...1 => 100...0, so shift is safe
                    mantissa >>= 1;
                    exp += 1;
                }
            }
        }
        mantissa >>= 1; // discard rounding bit.  Mantissa now scaled by 1<<Msize1.
        let f = util::ldexp(mantissa as f64, exp - msize1) as f32;
        if f.is_infinite() {
            (f, false)
        } else {
            (f, exact)
        }
    }
fn quo_to_f32 ( a : Nat , b : Nat ) -> ( f32 , bool ) { debug_assert ! ( a is_nan ( ) b is_nan ( ) ) ; debug_assert_ne ! ( b 0u32 ) ; let ( fsize , msize ) = ( 32 , 23 ) ; let ( msize1 , msize2 ) = ( msize + 1 , msize + 2 ) ; let esize = fsize - msize1 ; let ebias = ( 1 << ( esize - 1 ) ) - 1 ; let ( emin , _emax ) = ( 1 - ebias , ebias ) ; if a == 0u32 { ( 0f32 , true ) ; } let ( alen , blen ) = ( a . bits_len ( ) as isize , b . bits_len ( ) as isize ) ; // 1. Left-shift A or B such that quotient A/B is in [1<<Msize1, 1<<(Msize2+1) // (Msize2 bits if A < B when they are left-aligned, Msize2+1 bits if A >= B). // This is 2 or 3 more than the float32 mantissa field width of Msize: // - the optional extra bit is shifted away in step 3 below. // - the high-order 1 is omitted in "normal" representation; // - the low-order 1 will be used during rounding then discarded. let mut exp = alen - blen ; let ( shift , is_great ) = if msize2 > exp { ( ( msize2 - exp ) as usize , true ) } else { ( ( exp - msize2 ) as usize , false ) } ; let ( mut a2 , mut b2 ) = ( a . deep_clone ( ) , b . deep_clone ( ) ) ; if is_great { a2 . shl_inner ( & shift ) ; } else { b2 . shl_inner ( & shift ) ; } // 2. Compute quotient and remainder (q, r).  NB: due to the // extra shift, the low-order bit of q is logically the // high-order bit of r. // mantissa&1 && !haveRem => remainder is exactly half let ( q , r ) = ( a2 . clone ( ) / b2 . clone ( ) , a2 . clone ( ) % b2 . clone ( ) ) ; let ( mut mantissa , mut is_have_rem ) = ( q . as_vec ( ) [ 0 ] , r > 0u32 ) ; // mantissa&1 && !haveRem => remainder is exactly half // 3. If quotient didn't fit in Msize2 bits, redo division by b2<<1 // (in effect---we accomplish this incrementally). if ( mantissa >> msize2 ) == 1 { if mantissa & 1 == 1 { is_have_rem = true ; } mantissa >>= 1 ; exp += 1 ; } if ( mantissa >> msize1 ) != 1 { panic ! ( " " a b ) ; } // 4. Rounding. if ( emin - msize ) <= exp && exp <= emin { // Denormal case; lose 'shift' bits of precision. let shift = ( emin - ( exp - 1 ) ) as usize ; // [1..Esize1) let lostbits = mantissa & ( ( 1 << shift ) - 1 ) ; is_have_rem = is_have_rem || lostbits != 0 ; mantissa >>= shift ; exp = 2 - ebias ; // == exp + shift } // Round q using round-half-to-even. let mut exact = ! is_have_rem ; if ( mantissa & 1 ) != 0 { exact = false ; if is_have_rem || ( mantissa & 2 ) != 0 { mantissa += 1 ; if mantissa >= ( 1 << msize2 ) { // Complete rollover 11...1 => 100...0, so shift is safe mantissa >>= 1 ; exp += 1 ; } } } mantissa >>= 1 ; // discard rounding bit.  Mantissa now scaled by 1<<Msize1. let f = util :: ldexp ( mantissa as f64 , exp - msize1 ) as f32 ; if f . is_infinite ( ) { ( f , false ) } else { ( f , exact ) } }
quotToFloat32 returns the non-negative float32 value
nearest to the quotient a/b, using round-to-even in
halfway cases.
quotToFloat32 returns the non - negative float32 value nearest to the quotient a / b using round - to - even in halfway cases .
a
Nat
b
Nat
a
Nat
b
Nat