[BACK]Return to divexact.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpz

Diff for /OpenXM_contrib/gmp/mpz/Attic/divexact.c between version 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2000/09/09 14:12:50 version 1.1.1.3, 2003/08/25 16:06:33
Line 1 
Line 1 
 /* mpz_divexact -- finds quotient when known that quot * den == num && den != 0.  /* mpz_divexact -- finds quotient when known that quot * den == num && den != 0.
   
 Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 2000 Free Software  Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002 Free
 Foundation, Inc.  Software Foundation, Inc.
   
 This file is part of the GNU MP Library.  This file is part of the GNU MP Library.
   
Line 36  MA 02111-1307, USA.  */
Line 36  MA 02111-1307, USA.  */
 #include "longlong.h"  #include "longlong.h"
   
 void  void
 #if __STDC__  
 mpz_divexact (mpz_ptr quot, mpz_srcptr num, mpz_srcptr den)  mpz_divexact (mpz_ptr quot, mpz_srcptr num, mpz_srcptr den)
 #else  
 mpz_divexact (quot, num, den)  
      mpz_ptr quot;  
      mpz_srcptr num;  
      mpz_srcptr den;  
 #endif  
 {  {
   mp_ptr qp, tp;    mp_ptr qp, tp;
   mp_size_t qsize, tsize;    mp_size_t qsize, tsize;
Line 74  mpz_divexact (quot, num, den)
Line 67  mpz_divexact (quot, num, den)
     {      {
       if (dsize == 1)        if (dsize == 1)
         {          {
           mpn_divmod_1 (qp, np, nsize, dp[0]);            MPN_DIVREM_OR_DIVEXACT_1 (qp, np, nsize, dp[0]);
           qsize -= qp[qsize - 1] == 0;            qsize -= qp[qsize - 1] == 0;
           quot->_mp_size = (num->_mp_size ^ den->_mp_size) >= 0 ? qsize : -qsize;            quot->_mp_size = (num->_mp_size ^ den->_mp_size) >= 0 ? qsize : -qsize;
           return;            return;
Line 109  mpz_divexact (quot, num, den)
Line 102  mpz_divexact (quot, num, den)
       count_trailing_zeros (r, dp[0]);        count_trailing_zeros (r, dp[0]);
       mpn_rshift (tp, dp, tsize, r);        mpn_rshift (tp, dp, tsize, r);
       if (dsize > tsize)        if (dsize > tsize)
         tp[tsize - 1] |= dp[tsize] << (BITS_PER_MP_LIMB - r);          tp[tsize - 1] |= (dp[tsize] << (GMP_NUMB_BITS - r)) & GMP_NUMB_MASK;
       mpn_rshift (qp, np, qsize, r);        mpn_rshift (qp, np, qsize, r);
       if (nsize > qsize)        if (nsize > qsize)
         qp[qsize - 1] |= np[qsize] << (BITS_PER_MP_LIMB - r);          qp[qsize - 1] |= (np[qsize] << (GMP_NUMB_BITS - r)) & GMP_NUMB_MASK;
     }      }
   
   /*  Now QUOT <-- QUOT/T.  */    /*  Now QUOT <-- QUOT/T.  */
   mpn_bdivmod (qp, qp, qsize, tp, tsize, qsize * BITS_PER_MP_LIMB);    mpn_bdivmod (qp, qp, qsize, tp, tsize, qsize * GMP_NUMB_BITS);
   MPN_NORMALIZE (qp, qsize);    MPN_NORMALIZE (qp, qsize);
   
   quot->_mp_size = (num->_mp_size ^ den->_mp_size) >= 0 ? qsize : -qsize;    quot->_mp_size = (num->_mp_size ^ den->_mp_size) >= 0 ? qsize : -qsize;

Legend:
Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>