summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2012-03-02 19:33:50 +0000
committerenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2012-03-02 19:33:50 +0000
commit8a7e70572083c8d964bcbf7297a4d2868835f225 (patch)
tree0cc053e0fe680c6d7426a184dff112e4d3c22299 /src
parentbef243d0bdd8914b1f7a364b1dd32f3df882c389 (diff)
downloadmpc-8a7e70572083c8d964bcbf7297a4d2868835f225.tar.gz
sqr.c, mul.c: in the naive algorithm, redo computations with exact exponents
in more cases; corrects bug for test + - 10 0b1e-1073741824 10 0 100 0b1@-536870912 100 0b1@-536870913 N N (not yet added to sqr.dat) git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@1134 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'src')
-rw-r--r--src/mul.c9
-rw-r--r--src/sqr.c7
2 files changed, 7 insertions, 9 deletions
diff --git a/src/mul.c b/src/mul.c
index a85fa84..6d64329 100644
--- a/src/mul.c
+++ b/src/mul.c
@@ -1,6 +1,6 @@
/* mpc_mul -- Multiply two complex numbers
-Copyright (C) 2002, 2004, 2005, 2008, 2009, 2010, 2011 INRIA
+Copyright (C) 2002, 2004, 2005, 2008, 2009, 2010, 2011, 2012 INRIA
This file is part of GNU MPC.
@@ -201,10 +201,9 @@ mpfr_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c,
mpfr_set_si (z, (mpfr_signbit (z) ? -1 : 1), GMP_RNDN);
inex = mpfr_mul_2ui (z, z, mpfr_get_emax (), rnd);
}
- else if (mpfr_nan_p (z) || (mpfr_zero_p (u) && mpfr_zero_p (v))) {
- /* In the first case, u and v are infinities with opposite signs.
- In the second case, u and v are zeroes; their sum may be 0 or the
- least representable number, with a sign to be determined.
+ else if (mpfr_inf_p (u) || mpfr_inf_p (v)
+ || mpfr_zero_p (u) || mpfr_zero_p (v)) {
+ /* There is at least one over- or underflow.
Redo the computations with mpz_t exponents */
mpfr_exp_t ea, eb, ec, ed;
mpz_t eu, ev;
diff --git a/src/sqr.c b/src/sqr.c
index 47a3f7e..b5be792 100644
--- a/src/sqr.c
+++ b/src/sqr.c
@@ -58,10 +58,9 @@ mpfr_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c,
mpfr_set_si (z, (mpfr_signbit (z) ? -1 : 1), GMP_RNDN);
inex = mpfr_mul_2ui (z, z, mpfr_get_emax (), rnd);
}
- else if (mpfr_nan_p (z) || (mpfr_zero_p (u) && mpfr_zero_p (v))) {
- /* In the first case, u and v are infinities with opposite signs.
- In the second case, u and v are zeroes; their sum may be 0 or the
- least representable number, with a sign to be determined.
+ else if (mpfr_inf_p (u) || mpfr_inf_p (v)
+ || mpfr_zero_p (u) || mpfr_zero_p (v)) {
+ /* There is at least one over- or underflow.
Redo the computations with mpz_t exponents */
mpfr_exp_t ea, eb, ec, ed;
mpz_t eu, ev;