summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2003-04-23 23:43:47 +0200
committerKevin Ryde <user42@zip.com.au>2003-04-23 23:43:47 +0200
commit55e155a8755dd869bb2d7a80cb0e75ace8cf75da (patch)
tree93f26ee754de72ba99b5b29ef26bd78f53533214
parentcf900ae3fb8f8bd2bafa39bf4ad09922bdeef7a2 (diff)
downloadgmp-55e155a8755dd869bb2d7a80cb0e75ace8cf75da.tar.gz
* mpz/set_d.c, mpq/set_d.c, mpf/set_d.c: Nan or Inf invalid.
-rw-r--r--mpf/set_d.c14
-rw-r--r--mpq/set_d.c12
-rw-r--r--mpz/set_d.c12
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 <float.h> /* 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 <float.h> /* 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 <float.h> /* 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);