From 55e155a8755dd869bb2d7a80cb0e75ace8cf75da Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Wed, 23 Apr 2003 23:43:47 +0200 Subject: * mpz/set_d.c, mpq/set_d.c, mpf/set_d.c: Nan or Inf invalid. --- mpf/set_d.c | 14 ++++++++++++-- mpq/set_d.c | 12 +++++++++++- mpz/set_d.c | 12 +++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/mpf/set_d.c b/mpf/set_d.c index 9a8ff35a7..f639496c2 100644 --- a/mpf/set_d.c +++ b/mpf/set_d.c @@ -1,6 +1,6 @@ -/* mpf_set_d -- Assign a float from a IEEE double. +/* mpf_set_d -- Assign a float from a double. -Copyright 1993, 1994, 1995, 1996, 2001 Free Software Foundation, Inc. +Copyright 1993, 1994, 1995, 1996, 2001, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -19,6 +19,12 @@ 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. */ +#include "config.h" + +#if HAVE_FLOAT_H +#include /* for DBL_MAX */ +#endif + #include "gmp.h" #include "gmp-impl.h" @@ -27,6 +33,10 @@ mpf_set_d (mpf_ptr r, double d) { int negative; + DOUBLE_NAN_INF_ACTION (d, + __gmp_invalid_operation (), + __gmp_invalid_operation ()); + if (d == 0) { SIZ(r) = 0; diff --git a/mpq/set_d.c b/mpq/set_d.c index a5bd12aac..a154338bb 100644 --- a/mpq/set_d.c +++ b/mpq/set_d.c @@ -1,6 +1,6 @@ /* mpq_set_d(mpq_t q, double d) -- Set q to d without rounding. -Copyright 2000, 2002 Free Software Foundation, Inc. +Copyright 2000, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -19,6 +19,12 @@ 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. */ +#include "config.h" + +#if HAVE_FLOAT_H +#include /* for DBL_MAX */ +#endif + #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" @@ -37,6 +43,10 @@ mpq_set_d (mpq_ptr dest, double d) mp_size_t nn, dn; int c; + DOUBLE_NAN_INF_ACTION (d, + __gmp_invalid_operation (), + __gmp_invalid_operation ()); + negative = d < 0; d = ABS (d); diff --git a/mpz/set_d.c b/mpz/set_d.c index 0ec74e24a..07b6ef83d 100644 --- a/mpz/set_d.c +++ b/mpz/set_d.c @@ -1,6 +1,6 @@ /* mpz_set_d(integer, val) -- Assign INTEGER with a double value VAL. -Copyright 1995, 1996, 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 1995, 1996, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -19,6 +19,12 @@ 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. */ +#include "config.h" + +#if HAVE_FLOAT_H +#include /* for DBL_MAX */ +#endif + #include "gmp.h" #include "gmp-impl.h" @@ -30,6 +36,10 @@ mpz_set_d (mpz_ptr r, double d) mp_ptr rp; mp_size_t rn; + DOUBLE_NAN_INF_ACTION (d, + __gmp_invalid_operation (), + __gmp_invalid_operation ()); + negative = d < 0; d = ABS (d); -- cgit v1.2.1