diff options
author | Kevin Ryde <user42@zip.com.au> | 2003-04-23 23:45:33 +0200 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2003-04-23 23:45:33 +0200 |
commit | 584b78ceee967831c4713026c59b6d5ef2d5c174 (patch) | |
tree | 7657c7f705b844390db54176b89858c06629b906 /mpz/cmp_d.c | |
parent | 55e155a8755dd869bb2d7a80cb0e75ace8cf75da (diff) | |
download | gmp-584b78ceee967831c4713026c59b6d5ef2d5c174.tar.gz |
* mpz/cmp_d.c, mpz_cmpabs_d.c, mpf/cmp_d.c: NaN invalid, Inf bigger
than any value.
Diffstat (limited to 'mpz/cmp_d.c')
-rw-r--r-- | mpz/cmp_d.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/mpz/cmp_d.c b/mpz/cmp_d.c index de63b189e..d7dbe57eb 100644 --- a/mpz/cmp_d.c +++ b/mpz/cmp_d.c @@ -1,6 +1,6 @@ /* mpz_cmp_d -- compare absolute values of mpz and double. -Copyright 2001, 2002 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -17,8 +17,13 @@ License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. -*/ +MA 02111-1307, USA. */ + +#include "config.h" + +#if HAVE_FLOAT_H +#include <float.h> /* for DBL_MAX */ +#endif #include "gmp.h" #include "gmp-impl.h" @@ -50,12 +55,19 @@ mpz_cmp_d (mpz_srcptr z, double d) mp_size_t zsize; int dexp, ret; + /* d=NaN is an invalid operation, there's no sensible return value. + d=Inf or -Inf is always bigger than z. */ + DOUBLE_NAN_INF_ACTION (d, __gmp_invalid_operation (), goto z_zero); + /* 1. Either operand zero. */ zsize = SIZ(z); if (d == 0.0) return zsize; if (zsize == 0) - return (d < 0.0 ? 1 : -1); + { + z_zero: + return (d < 0.0 ? 1 : -1); + } /* 2. Opposite signs. */ if (zsize >= 0) |