version 1.1, 2000/09/09 14:12:50 |
version 1.1.1.2, 2003/08/25 16:06:33 |
|
|
/* mpz_cmpabs(u,v) -- Compare U, V. Return postive, zero, or negative |
/* mpz_cmpabs(u,v) -- Compare U, V. Return postive, zero, or negative |
based on if U > V, U == V, or U < V. |
based on if U > V, U == V, or U < V. |
|
|
Copyright (C) 1991, 1993, 1994, 1996, 1997, 2000 Free Software Foundation, |
Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001 Free Software Foundation, |
Inc. |
Inc. |
|
|
This file is part of the GNU MP Library. |
This file is part of the GNU MP Library. |
Line 24 MA 02111-1307, USA. */ |
|
Line 24 MA 02111-1307, USA. */ |
|
#include "gmp.h" |
#include "gmp.h" |
#include "gmp-impl.h" |
#include "gmp-impl.h" |
|
|
|
|
int |
int |
#if __STDC__ |
|
mpz_cmpabs (mpz_srcptr u, mpz_srcptr v) |
mpz_cmpabs (mpz_srcptr u, mpz_srcptr v) |
#else |
|
mpz_cmpabs (u, v) |
|
mpz_srcptr u; |
|
mpz_srcptr v; |
|
#endif |
|
{ |
{ |
mp_size_t usize = u->_mp_size; |
mp_size_t usize, vsize, dsize; |
mp_size_t vsize = v->_mp_size; |
mp_srcptr up, vp; |
mp_size_t size; |
int cmp; |
mp_srcptr up, vp; |
|
int cmp; |
|
|
|
usize = ABS (usize); |
usize = ABSIZ (u); |
vsize = ABS (vsize); |
vsize = ABSIZ (v); |
|
dsize = usize - vsize; |
|
if (dsize != 0) |
|
return dsize; |
|
|
if (usize != vsize) |
up = PTR(u); |
return usize - vsize; |
vp = PTR(v); |
|
MPN_CMP (cmp, up, vp, usize); |
if (usize == 0) |
|
return 0; |
|
|
|
up = u->_mp_d; |
|
vp = v->_mp_d; |
|
|
|
cmp = mpn_cmp (up, vp, usize); |
|
|
|
return cmp; |
return cmp; |
} |
} |