summaryrefslogtreecommitdiff
path: root/set_d.c
diff options
context:
space:
mode:
authorhanrot <hanrot@280ebfd0-de03-0410-8827-d642c229c3f4>2000-11-21 15:21:33 +0000
committerhanrot <hanrot@280ebfd0-de03-0410-8827-d642c229c3f4>2000-11-21 15:21:33 +0000
commitebb0a24940eb551ce03eb361910c423fee7d6499 (patch)
tree46fccc5920d05d93d00ecd30aff4a012adba3d13 /set_d.c
parent1cc85c4f5a5658c530891f7348c153155b6dddbb (diff)
downloadmpfr-ebb0a24940eb551ce03eb361910c423fee7d6499.tar.gz
Infinis, premiere tentative.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@793 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'set_d.c')
-rw-r--r--set_d.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/set_d.c b/set_d.c
index 15851d12b..d4353be1d 100644
--- a/set_d.c
+++ b/set_d.c
@@ -31,6 +31,8 @@ extern int isnan(double);
#include "mpfr.h"
#define NaN sqrt(-1) /* ensures a machine-independent NaN */
+#define Infp 1/0.
+#define Infm -1/0.
/* Included from gmp-2.0.2, patched to support denorms */
@@ -247,6 +249,12 @@ mpfr_set_d(r, d, rnd_mode)
if (d == 0) { MPFR_SET_ZERO(r); return; }
else if (isnan(d)) { MPFR_SET_NAN(r); return; }
+ else if (isinf(d))
+ {
+ MPFR_SET_INF(r);
+ if ((d > 0 && (MPFR_SIGN(r) == -1)) || (d < 0 && (MPFR_SIGN(r) == 1)))
+ MPFR_CHANGE_SIGN(r);
+ }
signd = (d < 0) ? -1 : 1;
d = ABS (d);
@@ -290,6 +298,12 @@ mpfr_get_d2(src, e)
printf("recognized NaN\n");
#endif
return NaN; }
+ if (MPFR_IS_INF(src)) {
+#ifdef DEBUG
+ printf("Found Inf.\n");
+#endif
+ return (MPFR_SIGN(src) == 1 ? Infp : Infm);
+ }
if (MPFR_NOTZERO(src)==0) return 0.0;
size = 1+(MPFR_PREC(src)-1)/BITS_PER_MP_LIMB;
qp = MPFR_MANT(src);