summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2005-08-24 15:37:36 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2005-08-24 15:37:36 +0000
commitac6c37d815d6c7a02f061020553b06103c9a9c87 (patch)
tree700252b8fe52ee16ae5fd17bb633c9dff960755b
parent9ecf5f8a64daa1d9bb136827152e31e60ad004a6 (diff)
downloadmpfr-ac6c37d815d6c7a02f061020553b06103c9a9c87.tar.gz
When WANT_ASSERT >= 2: the corresponding messages are now output
to stderr instead of stdout. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3737 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--add1sp.c25
-rw-r--r--mpfr-impl.h3
-rw-r--r--mul.c22
-rw-r--r--print_raw.c22
-rw-r--r--sub1sp.c25
5 files changed, 56 insertions, 41 deletions
diff --git a/add1sp.c b/add1sp.c
index 25b5edcbc..d3e9d69cf 100644
--- a/add1sp.c
+++ b/add1sp.c
@@ -45,18 +45,19 @@ int mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
if (mpfr_cmp (tmpa, a) || inexact != inexact2)
{
- printf("add1 & add1sp return different values for %s\n"
- "Prec_a= %lu Prec_b= %lu Prec_c= %lu\nB=",
- mpfr_print_rnd_mode (rnd_mode),
- MPFR_PREC (a), MPFR_PREC (b), MPFR_PREC (c));
- mpfr_print_binary (tmpb);
- printf("\nC=");
- mpfr_print_binary (tmpc);
- printf("\n\nadd1 : ");
- mpfr_print_binary (tmpa);
- printf("\nadd1sp: ");
- mpfr_print_binary (a);
- printf("\nInexact sp = %d | Inexact = %d\n", inexact, inexact2);
+ fprintf (stderr, "add1 & add1sp return different values for %s\n"
+ "Prec_a = %lu, Prec_b = %lu, Prec_c = %lu\nB = ",
+ mpfr_print_rnd_mode (rnd_mode),
+ MPFR_PREC (a), MPFR_PREC (b), MPFR_PREC (c));
+ mpfr_fprint_binary (stderr, tmpb);
+ fprintf (stderr, "\nC = ");
+ mpfr_fprint_binary (stderr, tmpc);
+ fprintf (stderr, "\n\nadd1 : ");
+ mpfr_fprint_binary (stderr, tmpa);
+ fprintf (stderr, "\nadd1sp: ");
+ mpfr_fprint_binary (stderr, a);
+ fprintf (stderr, "\nInexact sp = %d | Inexact = %d\n",
+ inexact, inexact2);
MPFR_ASSERTN (0);
}
mpfr_clears (tmpa, tmpb, tmpc, NULL);
diff --git a/mpfr-impl.h b/mpfr-impl.h
index a8ba46f34..0f0ffe9f8 100644
--- a/mpfr-impl.h
+++ b/mpfr-impl.h
@@ -1457,6 +1457,9 @@ __MPFR_DECLSPEC void mpfr_setmin _MPFR_PROTO ((mpfr_ptr, mp_exp_t));
__MPFR_DECLSPEC long mpfr_mpn_exp _MPFR_PROTO ((mp_limb_t *, mp_exp_t *, int,
mp_exp_t, size_t));
+#ifdef WANT_ASSERT
+__MPFR_DECLSPEC void mpfr_fprint_binary _MPFR_PROTO ((FILE *, mpfr_srcptr));
+#endif
__MPFR_DECLSPEC void mpfr_print_binary _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC void mpfr_print_mant_binary _MPFR_PROTO ((const char*,
const mp_limb_t*, mp_prec_t));
diff --git a/mul.c b/mul.c
index cc4fb476a..86c026309 100644
--- a/mul.c
+++ b/mul.c
@@ -175,15 +175,19 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
if (mpfr_cmp (ta, a) || inexact1*inexact2 < 0
|| (inexact1*inexact2 == 0 && (inexact1|inexact2) != 0))
{
- printf("mpfr_mul return different values for %s\n"
- "Prec_a= %lu Prec_b= %lu Prec_c= %lu\nB=",
- mpfr_print_rnd_mode (rnd_mode),
- MPFR_PREC (a), MPFR_PREC (b), MPFR_PREC (c));
- mpfr_out_str (stdout, 16, 0, tb, GMP_RNDN);
- printf("\nC="); mpfr_out_str (stdout, 16, 0, tc, GMP_RNDN);
- printf("\nOldMul: "); mpfr_out_str (stdout, 16, 0, ta, GMP_RNDN);
- printf("\nNewMul: "); mpfr_out_str (stdout, 16, 0, a, GMP_RNDN);
- printf("\nNewInexact = %d | OldInexact = %d\n", inexact1, inexact2);
+ fprintf (stderr, "mpfr_mul return different values for %s\n"
+ "Prec_a = %lu, Prec_b = %lu, Prec_c = %lu\nB = ",
+ mpfr_print_rnd_mode (rnd_mode),
+ MPFR_PREC (a), MPFR_PREC (b), MPFR_PREC (c));
+ mpfr_out_str (stderr, 16, 0, tb, GMP_RNDN);
+ fprintf (stderr, "\nC = ");
+ mpfr_out_str (stderr, 16, 0, tc, GMP_RNDN);
+ fprintf (stderr, "\nOldMul: ");
+ mpfr_out_str (stderr, 16, 0, ta, GMP_RNDN);
+ fprintf (stderr, "\nNewMul: ");
+ mpfr_out_str (stderr, 16, 0, a, GMP_RNDN);
+ fprintf (stderr, "\nNewInexact = %d | OldInexact = %d\n",
+ inexact1, inexact2);
MPFR_ASSERTN(0);
}
diff --git a/print_raw.c b/print_raw.c
index 5e8493274..044e04d56 100644
--- a/print_raw.c
+++ b/print_raw.c
@@ -26,21 +26,21 @@ MA 02110-1301, USA. */
#include "mpfr-impl.h"
void
-mpfr_print_binary (mpfr_srcptr x)
+mpfr_fprint_binary (FILE *stream, mpfr_srcptr x)
{
if (MPFR_IS_NAN (x))
{
- printf ("@NaN@");
+ fprintf (stream, "@NaN@");
return;
}
if (MPFR_SIGN (x) < 0)
- printf ("-");
+ fprintf (stream, "-");
if (MPFR_IS_INF (x))
- printf ("@Inf@");
+ fprintf (stream, "@Inf@");
else if (MPFR_IS_ZERO (x))
- printf ("0");
+ fprintf (stream, "0");
else
{
mp_limb_t *mx;
@@ -50,7 +50,7 @@ mpfr_print_binary (mpfr_srcptr x)
mx = MPFR_MANT (x);
px = MPFR_PREC (x);
- printf ("0.");
+ fprintf (stream, "0.");
for (n = (px - 1) / BITS_PER_MP_LIMB; ; n--)
{
mp_limb_t wd, t;
@@ -59,14 +59,14 @@ mpfr_print_binary (mpfr_srcptr x)
wd = mx[n];
for (t = MPFR_LIMB_HIGHBIT; t != 0; t >>= 1)
{
- printf ((wd & t) == 0 ? "0" : "1");
+ putc ((wd & t) == 0 ? '0' : '1', stream);
if (--px == 0)
{
mp_exp_t ex;
ex = MPFR_GET_EXP (x);
MPFR_ASSERTN (ex >= LONG_MIN && ex <= LONG_MAX);
- printf ("E%ld", (long) ex);
+ fprintf (stream, "E%ld", (long) ex);
return;
}
}
@@ -75,6 +75,12 @@ mpfr_print_binary (mpfr_srcptr x)
}
void
+mpfr_print_binary (mpfr_srcptr x)
+{
+ mpfr_fprint_binary (stdout, x);
+}
+
+void
mpfr_print_mant_binary(const char *str, const mp_limb_t *p, mp_prec_t r)
{
int i;
diff --git a/sub1sp.c b/sub1sp.c
index e45a317a2..255473b20 100644
--- a/sub1sp.c
+++ b/sub1sp.c
@@ -45,18 +45,19 @@ int mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
if (mpfr_cmp (tmpa, a) || inexact != inexact2)
{
- printf("sub1 & sub1sp return different values for %s\n"
- "Prec_a= %lu Prec_b= %lu Prec_c= %lu\nB=",
- mpfr_print_rnd_mode(rnd_mode),
- MPFR_PREC (a), MPFR_PREC (b), MPFR_PREC (c));
- mpfr_print_binary (tmpb);
- printf("\nC=");
- mpfr_print_binary (tmpc);
- printf("\nSub1 : ");
- mpfr_print_binary (tmpa);
- printf("\nSub1sp: ");
- mpfr_print_binary (a);
- printf("\nInexact sp = %d | Inexact = %d\n", inexact, inexact2);
+ fprintf (stderr, "sub1 & sub1sp return different values for %s\n"
+ "Prec_a = %lu, Prec_b = %lu, Prec_c = %lu\nB = ",
+ mpfr_print_rnd_mode(rnd_mode),
+ MPFR_PREC (a), MPFR_PREC (b), MPFR_PREC (c));
+ mpfr_fprint_binary (stderr, tmpb);
+ fprintf (stderr, "\nC = ");
+ mpfr_fprint_binary (stderr, tmpc);
+ fprintf (stderr, "\nSub1 : ");
+ mpfr_fprint_binary (stderr, tmpa);
+ fprintf (stderr, "\nSub1sp: ");
+ mpfr_fprint_binary (stderr, a);
+ fprintf (stderr, "\nInexact sp = %d | Inexact = %d\n",
+ inexact, inexact2);
MPFR_ASSERTN (0);
}
mpfr_clears (tmpa, tmpb, tmpc, NULL);