summaryrefslogtreecommitdiff
path: root/tests/tfactorial.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tfactorial.c')
-rw-r--r--tests/tfactorial.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/tests/tfactorial.c b/tests/tfactorial.c
index 7379827b7..4f9cff08d 100644
--- a/tests/tfactorial.c
+++ b/tests/tfactorial.c
@@ -152,55 +152,55 @@ main (int argc, char *argv[])
mpfr_set_prec (y, yprec);
for (n = 0; n < 50; n++)
- for (rnd = 0; rnd < GMP_RND_MAX; rnd++)
- {
- inexact = mpfr_fac_ui (y, n, (mp_rnd_t) rnd);
- err = (rnd == GMP_RNDN) ? yprec + 1 : yprec;
- if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec))
- {
- mpfr_set (t, y, (mp_rnd_t) rnd);
- inexact = mpfr_fac_ui (z, n, (mp_rnd_t) rnd);
- /* fact(n) ends with floor(n/2)+floor(n/4)+... zeros */
- for (k=n/2, zeros=0; k; k >>= 1)
- zeros += k;
- if (MPFR_EXP(y) <= (mp_exp_t) (prec + zeros))
- /* result should be exact */
- {
- if (inexact)
- {
- printf ("Wrong inexact flag: expected exact\n");
- exit (1);
- }
- }
- else /* result is inexact */
- {
- if (!inexact)
- {
- printf ("Wrong inexact flag: expected inexact\n");
- printf ("n=%u prec=%u\n", n, prec);
- mpfr_print_binary(z); puts ("");
- exit (1);
- }
- }
- if (mpfr_cmp (t, z))
- {
- printf ("results differ for x=");
- mpfr_out_str (stdout, 2, prec, x, GMP_RNDN);
- printf (" prec=%u rnd_mode=%s\n", prec,
- mpfr_print_rnd_mode ((mp_rnd_t) rnd));
- printf (" got ");
- mpfr_out_str (stdout, 2, prec, z, GMP_RNDN);
- puts ("");
- printf (" expected ");
- mpfr_out_str (stdout, 2, prec, t, GMP_RNDN);
- puts ("");
- printf (" approximation was ");
- mpfr_print_binary (y);
- puts ("");
- exit (1);
- }
- }
- }
+ for (rnd = 0; rnd < GMP_RND_MAX; rnd++)
+ {
+ inexact = mpfr_fac_ui (y, n, (mp_rnd_t) rnd);
+ err = (rnd == GMP_RNDN) ? yprec + 1 : yprec;
+ if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec))
+ {
+ mpfr_set (t, y, (mp_rnd_t) rnd);
+ inexact = mpfr_fac_ui (z, n, (mp_rnd_t) rnd);
+ /* fact(n) ends with floor(n/2)+floor(n/4)+... zeros */
+ for (k=n/2, zeros=0; k; k >>= 1)
+ zeros += k;
+ if (MPFR_EXP(y) <= (mp_exp_t) (prec + zeros))
+ /* result should be exact */
+ {
+ if (inexact)
+ {
+ printf ("Wrong inexact flag: expected exact\n");
+ exit (1);
+ }
+ }
+ else /* result is inexact */
+ {
+ if (!inexact)
+ {
+ printf ("Wrong inexact flag: expected inexact\n");
+ printf ("n=%u prec=%u\n", n, prec);
+ mpfr_print_binary(z); puts ("");
+ exit (1);
+ }
+ }
+ if (mpfr_cmp (t, z))
+ {
+ printf ("results differ for x=");
+ mpfr_out_str (stdout, 2, prec, x, GMP_RNDN);
+ printf (" prec=%u rnd_mode=%s\n", prec,
+ mpfr_print_rnd_mode ((mp_rnd_t) rnd));
+ printf (" got ");
+ mpfr_out_str (stdout, 2, prec, z, GMP_RNDN);
+ puts ("");
+ printf (" expected ");
+ mpfr_out_str (stdout, 2, prec, t, GMP_RNDN);
+ puts ("");
+ printf (" approximation was ");
+ mpfr_print_binary (y);
+ puts ("");
+ exit (1);
+ }
+ }
+ }
}
mpfr_clear (x);