~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/gmp/mpz/gcd_ui.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2007-04-09 11:51:51 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070409115151-ql8cr0kalzx1jmla
Tags: 0.9i-20070324-2
Upload to unstable. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* mpz_gcd_ui -- Calculate the greatest common divisior of two integers.
2
2
 
3
 
Copyright 1994, 1996, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
4
 
Inc.
 
3
Copyright 1994, 1996, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
 
4
Foundation, Inc.
5
5
 
6
6
This file is part of the GNU MP Library.
7
7
 
17
17
 
18
18
You should have received a copy of the GNU Lesser General Public License
19
19
along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
20
 
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21
 
MA 02111-1307, USA. */
 
20
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
21
MA 02110-1301, USA. */
22
22
 
23
23
#include <stdio.h> /* for NULL */
24
24
#include "gmp.h"
30
30
  mp_size_t un;
31
31
  mp_limb_t res;
32
32
 
33
 
#if GMP_NAIL_BITS != 0
 
33
#if BITS_PER_ULONG > GMP_NUMB_BITS  /* avoid warnings about shift amount */
34
34
  if (v > GMP_NUMB_MAX)
35
35
    {
36
36
      mpz_t vz;
40
40
      PTR(vz) = vlimbs;
41
41
      SIZ(vz) = 2;
42
42
      mpz_gcd (w, u, vz);
43
 
      return;
 
43
      /* because v!=0 we will have w<=v hence fitting a ulong */
 
44
      ASSERT (mpz_fits_ulong_p (w));
 
45
      return mpz_get_ui (w);
44
46
    }
45
47
#endif
46
48