summaryrefslogtreecommitdiff
path: root/set_ld.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-12-01 10:25:01 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-12-01 10:25:01 +0000
commitb2f4e6bf9660bc322f5f1145d77d26ba41a153fd (patch)
tree91e6474e6397e7d7806a789a906109b728770109 /set_ld.c
parent2599eb53f9946b1879d0657098027d29bf191a28 (diff)
downloadmpfr-b2f4e6bf9660bc322f5f1145d77d26ba41a153fd.tar.gz
Port all the IEEE dependent remaining functions so that it uses a generic way to compute the result if it detects that the double is not in IEEE format ( _GMP_IEEE_FLOATS == 0).
MPFR now should work well on non-IEEE machines. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2567 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'set_ld.c')
-rw-r--r--set_ld.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/set_ld.c b/set_ld.c
index 055be494d..b99d7188d 100644
--- a/set_ld.c
+++ b/set_ld.c
@@ -120,35 +120,35 @@ mpfr_set_ld (mpfr_ptr r, long double d, mp_rnd_t rnd_mode)
/* since -DBL_MAX <= d <= DBL_MAX, the cast to double should not
overflow here */
mpfr_set_d (u, (double) d, GMP_RNDN);
- /* warning: using MPFR_IS_ZERO will cause a READ_UNINIT_MEM if u=Inf */
- if (mpfr_cmp_ui (u, 0) == 0 && (d != (long double) 0.0)) /* underflow */
- {
- long double div10, div11, div12, div13;
- div10 = (long double) (double) 5.5626846462680034577255e-309; /* 2^(-2^10) */
- div11 = div10 * div10; /* 2^(-2^11) */
- div12 = div11 * div11; /* 2^(-2^12) */
- div13 = div12 * div12; /* 2^(-2^13) */
- if (ABS(d) <= div13)
- {
- d = d / div13; /* exact */
- shift_exp -= 8192;
- }
- if (ABS(d) <= div12)
- {
- d = d / div12; /* exact */
- shift_exp -= 4096;
- }
- if (ABS(d) <= div11)
- {
- d = d / div11; /* exact */
- shift_exp -= 2048;
- }
- if (ABS(d) <= div10)
- {
- d = d / div10; /* exact */
- shift_exp -= 1024;
- }
- }
+ /* warning: using MPFR_IS_ZERO will cause a READ_UNINIT_MEM if u=Inf */
+ if (mpfr_cmp_ui (u, 0) == 0 && (d != (long double) 0.0)) /* underflow */
+ {
+ long double div10, div11, div12, div13;
+ div10 = (long double) (double) 5.5626846462680034577255e-309; /* 2^(-2^10) */
+ div11 = div10 * div10; /* 2^(-2^11) */
+ div12 = div11 * div11; /* 2^(-2^12) */
+ div13 = div12 * div12; /* 2^(-2^13) */
+ if (ABS(d) <= div13)
+ {
+ d = d / div13; /* exact */
+ shift_exp -= 8192;
+ }
+ if (ABS(d) <= div12)
+ {
+ d = d / div12; /* exact */
+ shift_exp -= 4096;
+ }
+ if (ABS(d) <= div11)
+ {
+ d = d / div11; /* exact */
+ shift_exp -= 2048;
+ }
+ if (ABS(d) <= div10)
+ {
+ d = d / div10; /* exact */
+ shift_exp -= 1024;
+ }
+ }
}
mpfr_add (t, t, u, GMP_RNDN); /* exact */
if (!mpfr_number_p (t))