static void check_intmax (void) { #ifdef _MPFR_H_HAVE_INTMAX_T mpfr_t x; mpfr_init2 (x, sizeof(uintmax_t)*CHAR_BIT); /* Check NAN */ mpfr_set_nan(x); if (mpfr_fits_uintmax_p(x, GMP_RNDN)) ERROR1; if (mpfr_fits_intmax_p(x, GMP_RNDN)) ERROR1; /* Check INF */ mpfr_set_inf(x, 1); if (mpfr_fits_uintmax_p(x, GMP_RNDN)) ERROR1; if (mpfr_fits_intmax_p(x, GMP_RNDN)) ERROR1; /* Check Zero */ MPFR_SET_ZERO(x); if (!mpfr_fits_uintmax_p(x, GMP_RNDN)) ERROR2; if (!mpfr_fits_intmax_p(x, GMP_RNDN)) ERROR2; /* Check small op */ mpfr_set_str1 (x, "1@-1"); if (!mpfr_fits_uintmax_p(x, GMP_RNDN)) ERROR2; if (!mpfr_fits_intmax_p(x, GMP_RNDN)) ERROR2; /* Check all other values */ mpfr_set_uj (x, UINTMAX_MAX, GMP_RNDN); mpfr_add_ui (x, x, 1, GMP_RNDN); if (mpfr_fits_uintmax_p (x, GMP_RNDN)) ERROR1; mpfr_set_uj (x, UINTMAX_MAX, GMP_RNDN); if (!mpfr_fits_uintmax_p (x, GMP_RNDN)) ERROR2; mpfr_set_sj (x, INTMAX_MAX, GMP_RNDN); mpfr_add_ui (x, x, 1, GMP_RNDN); if (mpfr_fits_intmax_p (x, GMP_RNDN)) ERROR1; mpfr_set_sj (x, INTMAX_MAX, GMP_RNDN); if (!mpfr_fits_intmax_p (x, GMP_RNDN)) ERROR2; mpfr_set_sj (x, INTMAX_MIN, GMP_RNDN); if (!mpfr_fits_intmax_p (x, GMP_RNDN)) ERROR2; mpfr_sub_ui (x, x, 1, GMP_RNDN); if (mpfr_fits_intmax_p (x, GMP_RNDN)) ERROR1; mpfr_clear (x); #endif }
static void check_intmax (void) { #ifdef _MPFR_H_HAVE_INTMAX_T mpfr_t x, y; int i, r; mpfr_init2 (x, sizeof (uintmax_t) * CHAR_BIT); mpfr_init2 (y, 8); RND_LOOP (r) { /* Check NAN */ mpfr_set_nan (x); if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r)) ERROR1 (52); if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r)) ERROR1 (53); /* Check INF */ mpfr_set_inf (x, 1); if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r)) ERROR1 (54); if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r)) ERROR1 (55); /* Check Zero */ MPFR_SET_ZERO (x); if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r)) ERROR1 (56); if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r)) ERROR1 (57); /* Check positive small op */ mpfr_set_str1 (x, "1@-1"); if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r)) ERROR1 (58); if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r)) ERROR1 (59); /* Check 17 */ mpfr_set_ui (x, 17, MPFR_RNDN); if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r)) ERROR1 (60); if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r)) ERROR1 (61); /* Check hugest */ mpfr_set_ui_2exp (x, 42, sizeof (uintmax_t) * 32, MPFR_RNDN); if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r)) ERROR1 (62); if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r)) ERROR1 (63); /* Check all other values */ mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN); mpfr_add_ui (x, x, 1, MPFR_RNDN); if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r)) ERROR1 (64); mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN); if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r)) ERROR1 (65); mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN); mpfr_add_ui (x, x, 1, MPFR_RNDN); if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r)) ERROR1 (66); mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN); if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r)) ERROR1 (67); mpfr_set_sj (x, MPFR_INTMAX_MIN, MPFR_RNDN); if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r)) ERROR1 (68); mpfr_sub_ui (x, x, 1, MPFR_RNDN); if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r)) ERROR1 (69); /* Check negative op */ for (i = 1; i <= 4; i++) { int inv; mpfr_set_si_2exp (x, -i, -2, MPFR_RNDN); mpfr_rint (y, x, (mpfr_rnd_t) r); inv = MPFR_NOTZERO (y); if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r) ^ inv) ERROR1 (70); if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r)) ERROR1 (71); } } mpfr_clear (x); mpfr_clear (y); #endif }