• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ set_emax函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中set_emax函数的典型用法代码示例。如果您正苦于以下问题:C++ set_emax函数的具体用法?C++ set_emax怎么用?C++ set_emax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了set_emax函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: special_overflow

static void
special_overflow (void)
{
  mpfr_t x, y;
  mpfr_exp_t emin, emax;

  emin = mpfr_get_emin ();
  emax = mpfr_get_emax ();

  set_emin (-125);
  set_emax (128);
  mpfr_init2 (x, 24);
  mpfr_init2 (y, 48);
  mpfr_set_str_binary (x, "0.101100100000000000110100E0");
  mpfr_asin (y, x, MPFR_RNDN);
  if (mpfr_cmp_str (y, "0.110001001101001111110000010110001000111011001000E0",
                    2, MPFR_RNDN))
    {
      printf("Special Overflow error.\n");
      mpfr_dump (y);
      exit (1);
    }
  mpfr_clear (y);
  mpfr_clear (x);
  set_emin (emin);
  set_emax (emax);
}
开发者ID:Canar,项目名称:mpfr,代码行数:27,代码来源:tasin.c


示例2: check_overflow

static void
check_overflow (void)
{
  mpfr_t x, y, z1, z2;
  mpfr_exp_t emin, emax;

  emin = mpfr_get_emin ();
  emax = mpfr_get_emax ();

  set_emin (-1021);
  set_emax (1024);

  mpfr_inits (x, y, z1, z2, (mpfr_ptr) 0);

  mpfr_set_str1 (x, "8.00468257869324898448e+307");
  mpfr_set_str1 (y, "7.44784712422708645156e+307");
  mpfr_add1sp (z1, x, y, MPFR_RNDN);
  mpfr_add1   (z2, x, y, MPFR_RNDN);
  if (mpfr_cmp (z1, z2))
    {
      printf ("Overflow bug in add1sp.\n");
      exit (1);
    }
  mpfr_clears (x, y, z1, z2, (mpfr_ptr) 0);

  set_emin (emin);
  set_emax (emax);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:28,代码来源:tadd1sp.c


示例3: special_overflow

static void
special_overflow (void)
{
  mpfr_t x, y;
  int inex;
  mpfr_exp_t emin, emax;

  emin = mpfr_get_emin ();
  emax = mpfr_get_emax ();

  set_emin (-125);
  set_emax (128);

  mpfr_init2 (x, 24);
  mpfr_init2 (y, 24);

  mpfr_set_str_binary (x, "0.101100100000000000110100E15");
  inex = mpfr_exp2 (y, x, MPFR_RNDN);
  if (!mpfr_inf_p (y) || inex <= 0)
    {
      printf ("Overflow error.\n");
      mpfr_dump (y);
      printf ("inex = %d\n", inex);
      exit (1);
    }

  mpfr_clear (y);
  mpfr_clear (x);
  set_emin (emin);
  set_emax (emax);
}
开发者ID:sudheesh001,项目名称:SEC-LAB,代码行数:31,代码来源:texp2.c


示例4: check_emax_aux

/* In particular, the following test makes sure that the rounding
 * for %Ra and %Rb is not done on the MPFR number itself (as it
 * would overflow). Note: it has been reported on comp.std.c that
 * some C libraries behave differently on %a, but this is a bug.
 */
static void
check_emax_aux (mpfr_exp_t e)
{
    mpfr_t x;
    char *s1, s2[256];
    int i;
    mpfr_exp_t emax;

    MPFR_ASSERTN (e <= LONG_MAX);
    emax = mpfr_get_emax ();
    set_emax (e);

    mpfr_init2 (x, 16);

    mpfr_set_inf (x, 1);
    mpfr_nextbelow (x);

    i = mpfr_asprintf (&s1, "%Ra %.2Ra", x, x);
    MPFR_ASSERTN (i > 0);

    mpfr_snprintf (s2, 256, "0x7.fff8p+%ld 0x8.00p+%ld", e-3, e-3);

    if (strcmp (s1, s2) != 0)
    {
        printf ("Error in check_emax_aux for emax = ");
        if (e > LONG_MAX)
            printf ("(>LONG_MAX)\n");
        else
            printf ("%ld\n", (long) e);
        printf ("Expected %s\n", s2);
        printf ("Got      %s\n", s1);
        exit (1);
    }

    mpfr_free_str (s1);

    i = mpfr_asprintf (&s1, "%Rb %.2Rb", x, x);
    MPFR_ASSERTN (i > 0);

    mpfr_snprintf (s2, 256, "1.111111111111111p+%ld 1.00p+%ld", e-1, e);

    if (strcmp (s1, s2) != 0)
    {
        printf ("Error in check_emax_aux for emax = ");
        if (e > LONG_MAX)
            printf ("(>LONG_MAX)\n");
        else
            printf ("%ld\n", (long) e);
        printf ("Expected %s\n", s2);
        printf ("Got      %s\n", s1);
        exit (1);
    }

    mpfr_free_str (s1);

    mpfr_clear (x);
    set_emax (emax);
}
开发者ID:epowers,项目名称:mpfr,代码行数:63,代码来源:tsprintf.c


示例5: main

int
main (void)
{
  mpfr_t x, y, z, u;
  int inexact;
  mpfr_exp_t emax;

  tests_start_mpfr ();

  /* check prototypes of mpfr_init_set_* */
  inexact = mpfr_init_set_si (x, -1, MPFR_RNDN);
  inexact = mpfr_init_set (y, x, MPFR_RNDN);
  inexact = mpfr_init_set_ui (z, 1, MPFR_RNDN);
  inexact = mpfr_init_set_d (u, 1.0, MPFR_RNDN);

  emax = mpfr_get_emax ();
  set_emax (0);
  mpfr_set_prec (x, 3);
  mpfr_set_str_binary (x, "0.111");
  mpfr_set_prec (y, 2);
  mpfr_set (y, x, MPFR_RNDU);
  if (!(MPFR_IS_INF (y) && MPFR_SIGN (y) > 0))
    {
      printf ("Error for y=x=0.111 with px=3, py=2 and emax=0\nx=");
      mpfr_dump (x);
      printf ("y=");
      mpfr_dump (y);
      exit (1);
    }

  set_emax (emax);

  mpfr_set_prec (y, 11);
  mpfr_set_str_binary (y, "0.11111111100E-8");
  mpfr_set_prec (x, 2);
  mpfr_set (x, y, MPFR_RNDN);
  mpfr_set_str_binary (y, "1.0E-8");
  if (mpfr_cmp (x, y))
    {
      printf ("Error for y=0.11111111100E-8, prec=2, rnd=MPFR_RNDN\n");
      exit (1);
    }

  mpfr_clear (x);
  mpfr_clear (y);
  mpfr_clear (z);
  mpfr_clear (u);

  check_ternary_value ();
  check_special ();
  check_neg_special ();

  test_generic (2, 1000, 10);

  tests_end_mpfr ();
  return 0;
}
开发者ID:119,项目名称:aircam-openwrt,代码行数:57,代码来源:tset.c


示例6: special_overflow

static void
special_overflow (void)
{
  /* Check for overflow in 3 cases:
     1. cosh(x) is representable, but not exp(x)
     2. cosh(x) is not representable in the selected range of exp.
     3. cosh(x) exp overflow even with the largest range of exp */
  mpfr_t x, y;
  mp_exp_t emin, emax;

  emin = mpfr_get_emin ();
  emax = mpfr_get_emax ();

  set_emin (-125);
  set_emax (128);

  mpfr_init2 (x, 24);
  mpfr_init2 (y, 24);

  mpfr_set_str_binary (x, "0.101100100000000000110100E7");
  mpfr_cosh (y, x, GMP_RNDN);
  if (mpfr_cmp_str (y, "0.101010001111001010001110E128", 2, GMP_RNDN))
    {
      printf("Special overflow error 1.\n");
      mpfr_dump (y);
      exit (1);
    }

  mpfr_set_str_binary (x, "0.101100100000000000110100E8");
  mpfr_cosh (y, x, GMP_RNDN);
  if (!mpfr_inf_p(y))
    {
      printf("Special overflow error 2.\n");
      mpfr_dump (y);
      exit (1);
    }

  set_emin (emin);
  set_emax (emax);

  mpfr_set_str_binary (x, "0.101100100000000000110100E1000000");
  mpfr_cosh (y, x, GMP_RNDN);
  if (!mpfr_inf_p(y))
    {
      printf("Special overflow error 3.\n");
      mpfr_dump (y);
      exit (1);
    }

  mpfr_clear (y);
  mpfr_clear (x);
}
开发者ID:STAR111,项目名称:GCC_parser,代码行数:52,代码来源:tcosh.c


示例7: check_overflow

static void
check_overflow (void)
{
  mpfr_t sum1, sum2, x, y;
  mpfr_ptr t[2 * NOVFL];
  mpfr_exp_t emin, emax;
  int i, r;

  emin = mpfr_get_emin ();
  emax = mpfr_get_emax ();
  set_emin (MPFR_EMIN_MIN);
  set_emax (MPFR_EMAX_MAX);

  mpfr_inits2 (32, sum1, sum2, x, y, (mpfr_ptr) 0);
  mpfr_setmax (x, mpfr_get_emax ());
  mpfr_neg (y, x, MPFR_RNDN);

  for (i = 0; i < 2 * NOVFL; i++)
    t[i] = i < NOVFL ? x : y;

  /* Two kinds of test:
   *   i = 1: overflow.
   *   i = 2: intermediate overflow (exact sum is 0).
   */
  for (i = 1; i <= 2; i++)
    RND_LOOP(r)
      {
        int inex1, inex2;

        inex1 = mpfr_add (sum1, x, i == 1 ? x : y, (mpfr_rnd_t) r);
        inex2 = mpfr_sum (sum2, t, i * NOVFL, (mpfr_rnd_t) r);
        MPFR_ASSERTN (mpfr_check (sum1));
        MPFR_ASSERTN (mpfr_check (sum2));
        if (!(mpfr_equal_p (sum1, sum2) && SAME_SIGN (inex1, inex2)))
          {
            printf ("Error in check_overflow on %s, i = %d\n",
                    mpfr_print_rnd_mode ((mpfr_rnd_t) r), i);
            printf ("Expected ");
            mpfr_dump (sum1);
            printf ("with inex = %d\n", inex1);
            printf ("Got      ");
            mpfr_dump (sum2);
            printf ("with inex = %d\n", inex2);
            exit (1);
          }
      }

  mpfr_clears (sum1, sum2, x, y, (mpfr_ptr) 0);

  set_emin (emin);
  set_emax (emax);
}
开发者ID:BrianGladman,项目名称:mpfr,代码行数:52,代码来源:tsum.c


示例8: check_large

static void
check_large (void)
{
  mpz_t z;
  mpfr_t x, y;
  mpfr_exp_t emax, emin;

  mpz_init (z);
  mpfr_init2 (x, 160);
  mpfr_init2 (y, 160);

  mpz_set_str (z, "77031627725494291259359895954016675357279104942148788042", 10);
  mpfr_set_z (x, z, MPFR_RNDN);
  mpfr_set_str_binary (y, "0.1100100100001111110110101010001000100001011010001100001000110100110001001100011001100010100010111000000011011100000111001101000100101001000000100100111000001001E186");
  if (mpfr_cmp (x, y))
    {
      printf ("Error in mpfr_set_z on large input\n");
      exit (1);
    }

  /* check overflow */
  emax = mpfr_get_emax ();
  set_emax (2);
  mpz_set_str (z, "7", 10);
  mpfr_set_z (x, z, MPFR_RNDU);
  MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0);
  set_emax (3);
  mpfr_set_prec (x, 2);
  mpz_set_str (z, "7", 10);
  mpfr_set_z (x, z, MPFR_RNDU);
  MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0);
  set_emax (emax);

  /* check underflow */
  emin = mpfr_get_emin ();
  set_emin (3);
  mpz_set_str (z, "1", 10);
  mpfr_set_z (x, z, MPFR_RNDZ);
  MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_POS(x));
  set_emin (2);
  mpfr_set_z (x, z, MPFR_RNDN);
  MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_POS(x));
  set_emin (emin);

  mpz_clear (z);

  mpfr_clear (x);
  mpfr_clear (y);
}
开发者ID:BreakawayConsulting,项目名称:mpfr,代码行数:49,代码来源:tset_z.c


示例9: check_emin_emax

static void
check_emin_emax (void)
{
    mpfr_exp_t old_emin, old_emax;

    old_emin = mpfr_get_emin ();
    old_emax = mpfr_get_emax ();

    /* Check the functions not the macros ! */
    if ((mpfr_set_emin)(MPFR_EMIN_MIN) != 0)
        ERROR("set_emin failed!");
    if ((mpfr_get_emin)() != MPFR_EMIN_MIN)
        ERROR("get_emin FAILED!");
    if ((mpfr_set_emin)(MPFR_EMIN_MIN-1) == 0)
        ERROR("set_emin failed! (2)");

    if ((mpfr_set_emax)(MPFR_EMAX_MAX) != 0)
        ERROR("set_emax failed!");
    if ((mpfr_get_emax)() != MPFR_EMAX_MAX)
        ERROR("get_emax FAILED!");
    if ((mpfr_set_emax)(MPFR_EMAX_MAX+1) == 0)
        ERROR("set_emax failed! (2)");

    if ((mpfr_get_emin_min) () != MPFR_EMIN_MIN)
        ERROR ("get_emin_min");
    if ((mpfr_get_emin_max) () != MPFR_EMIN_MAX)
        ERROR ("get_emin_max");
    if ((mpfr_get_emax_min) () != MPFR_EMAX_MIN)
        ERROR ("get_emax_min");
    if ((mpfr_get_emax_max) () != MPFR_EMAX_MAX)
        ERROR ("get_emax_max");

    set_emin (old_emin);
    set_emax (old_emax);
}
开发者ID:gnooth,项目名称:xcl,代码行数:35,代码来源:texceptions.c


示例10: mpfr_set_double_range

static void
mpfr_set_double_range (void)
{
    mpfr_set_default_prec (54);
    if (mpfr_get_default_prec () != 54)
        ERROR ("get_default_prec failed (1)");
    mpfr_set_default_prec (53);
    if ((mpfr_get_default_prec) () != 53)
        ERROR ("get_default_prec failed (2)");

    /* in double precision format, the unbiased exponent is between 0 and
       2047, where 0 is used for subnormal numbers, and 2047 for special
       numbers (infinities, NaN), and the bias is 1023, thus "normal" numbers
       have an exponent between -1022 and 1023, corresponding to numbers
       between 2^(-1022) and previous(2^(1024)).
       (The smallest subnormal number is 0.(0^51)1*2^(-1022)= 2^(-1074).)

       The smallest normal power of two is 1.0*2^(-1022).
       The largest normal power of two is 2^1023.
       (We have to add one for mpfr since mantissa are between 1/2 and 1.)
    */

    set_emin (-1021);
    set_emax (1024);
}
开发者ID:gnooth,项目名称:xcl,代码行数:25,代码来源:texceptions.c


示例11: reduced_expo_range

/* https://sympa.inria.fr/sympa/arc/mpfr/2011-05/msg00008.html
 * Incorrect flags (in debug mode on a 32-bit machine, assertion failure).
 */
static void
reduced_expo_range (void)
{
    mpfr_exp_t emin, emax;
    mpfr_t x, y, ex_y;
    int inex, ex_inex;
    unsigned int flags, ex_flags;

    emin = mpfr_get_emin ();
    emax = mpfr_get_emax ();

    mpfr_inits2 (12, x, y, ex_y, (mpfr_ptr) 0);
    mpfr_set_str (x, "0.1e-5", 2, MPFR_RNDN);

    set_emin (-5);
    set_emax (-5);
    mpfr_clear_flags ();
    inex = mpfr_atan (y, x, MPFR_RNDN);
    flags = __gmpfr_flags;
    set_emin (emin);
    set_emax (emax);

    mpfr_set_str (ex_y, "0.1e-5", 2, MPFR_RNDN);
    ex_inex = 1;
    ex_flags = MPFR_FLAGS_INEXACT;

    if (SIGN (inex) != ex_inex || flags != ex_flags ||
            ! mpfr_equal_p (y, ex_y))
    {
        printf ("Error in reduced_expo_range\non x = ");
        mpfr_dump (x);
        printf ("Expected y = ");
        mpfr_out_str (stdout, 2, 0, ex_y, MPFR_RNDN);
        printf ("\n         inex = %d, flags = %u\n", ex_inex, ex_flags);
        printf ("Got      y = ");
        mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
        printf ("\n         inex = %d, flags = %u\n", SIGN (inex), flags);
        exit (1);
    }

    mpfr_clears (x, y, ex_y, (mpfr_ptr) 0);
}
开发者ID:Canar,项目名称:mpfr,代码行数:45,代码来源:tatan.c


示例12: main

int
main (int argc, char *argv[])
{
  mpfr_t x;
  int ret;
  mpfr_exp_t emin, emax;

  tests_start_mpfr ();

  emin = mpfr_get_emin ();
  emax = mpfr_get_emax ();

  mpfr_init (x);

  mpfr_set_ui (x, 1, MPFR_RNDN);
  ret = mpfr_set_exp (x, 2);
  MPFR_ASSERTN(ret == 0 && mpfr_cmp_ui (x, 2) == 0);

  set_emin (-1);
  ret = mpfr_set_exp (x, -1);
  MPFR_ASSERTN(ret == 0 && mpfr_cmp_ui_2exp (x, 1, -2) == 0);

  set_emax (1);
  ret = mpfr_set_exp (x, 1);
  MPFR_ASSERTN(ret == 0 && mpfr_cmp_ui (x, 1) == 0);

  ret = mpfr_set_exp (x, -2);
  MPFR_ASSERTN(ret != 0 && mpfr_cmp_ui (x, 1) == 0);

  ret = mpfr_set_exp (x, 2);
  MPFR_ASSERTN(ret != 0 && mpfr_cmp_ui (x, 1) == 0);

  mpfr_clear (x);

  set_emin (emin);
  set_emax (emax);

  tests_end_mpfr ();
  return 0;
}
开发者ID:SESA,项目名称:EbbRT-mpfr,代码行数:40,代码来源:tset_exp.c


示例13: check_reduced_exprange

static void
check_reduced_exprange (void)
{
  mpfr_t x;
  char *s;
  mpfr_exp_t emax, e;

  emax = mpfr_get_emax ();
  mpfr_init2 (x, 8);
  mpfr_set_str (x, "0.11111111E0", 2, MPFR_RNDN);
  set_emax (0);
  s = mpfr_get_str (NULL, &e, 16, 0, x, MPFR_RNDN);
  set_emax (emax);
  if (strcmp (s, "ff0"))
    {
      printf ("Error for mpfr_get_str on 0.11111111E0 in base 16:\n"
              "Got \"%s\" instead of \"ff0\".\n", s);
      exit (1);
    }
  mpfr_free_str (s);
  mpfr_clear (x);
}
开发者ID:BrianGladman,项目名称:mpfr,代码行数:22,代码来源:tget_str.c


示例14: special_overflow

static void
special_overflow (void)
{
  mpfr_t x, y;
  mpfr_exp_t emin, emax;

  emin = mpfr_get_emin ();
  emax = mpfr_get_emax ();

  mpfr_init2 (x, 24);
  mpfr_init2 (y, 73);

  /* Check special case: An overflow in const_pi could occurs! */
  set_emin (-125);
  set_emax (128);
  mpfr_set_str_binary (x, "0.111101010110110011101101E6");
  test_cos (y, x, MPFR_RNDZ);
  set_emin (emin);
  set_emax (emax);

  mpfr_clear (x);
  mpfr_clear (y);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:23,代码来源:tcos.c


示例15: check_flags

static void
check_flags (void)
{
    mpfr_t x;
    mpfr_exp_t old_emin, old_emax;

    old_emin = mpfr_get_emin ();
    old_emax = mpfr_get_emax ();
    mpfr_init (x);

    /* Check the functions not the macros ! */
    (mpfr_clear_flags)();
    mpfr_set_double_range ();

    mpfr_set_ui (x, 1, MPFR_RNDN);
    (mpfr_clear_overflow)();
    mpfr_mul_2exp (x, x, 1024, MPFR_RNDN);
    if (!(mpfr_overflow_p)())
        ERROR("ERROR: No overflow detected!\n");

    (mpfr_clear_underflow)();
    mpfr_set_ui (x, 1, MPFR_RNDN);
    mpfr_div_2exp (x, x, 1025, MPFR_RNDN);
    if (!(mpfr_underflow_p)())
        ERROR("ERROR: No underflow detected!\n");

    (mpfr_clear_nanflag)();
    MPFR_SET_NAN(x);
    mpfr_add (x, x, x, MPFR_RNDN);
    if (!(mpfr_nanflag_p)())
        ERROR("ERROR: No NaN flag!\n");

    (mpfr_clear_inexflag)();
    mpfr_set_ui(x, 2, MPFR_RNDN);
    mpfr_cos(x, x, MPFR_RNDN);
    if (!(mpfr_inexflag_p)())
        ERROR("ERROR: No inexact flag!\n");

    (mpfr_clear_erangeflag) ();
    mpfr_set_ui (x, 1, MPFR_RNDN);
    mpfr_mul_2exp (x, x, 1024, MPFR_RNDN);
    mpfr_get_ui (x, MPFR_RNDN);
    if (!(mpfr_erangeflag_p)())
        ERROR ("ERROR: No erange flag!\n");

    mpfr_clear (x);
    set_emin (old_emin);
    set_emax (old_emax);
}
开发者ID:gnooth,项目名称:xcl,代码行数:49,代码来源:texceptions.c


示例16: alltst

static void
alltst (void)
{
  mpfr_exp_t emin, emax;

  ext = 0;
  test_small ();
  test_large_small ();
  check_overflow ();

  emin = mpfr_get_emin ();
  emax = mpfr_get_emax ();
  set_emin (MPFR_EMIN_MIN);
  set_emax (MPFR_EMAX_MAX);
  if (mpfr_get_emin () != emin || mpfr_get_emax () != emax)
    {
      ext = 1;
      test_small ();
      test_large_small ();
      check_overflow ();
      set_emin (emin);
      set_emax (emax);
    }
}
开发者ID:Kirija,项目名称:XPIR,代码行数:24,代码来源:thypot.c


示例17: alltst

static void
alltst (void)
{
  mpfr_exp_t emin, emax;

  ext = 0;
  tst ();
  underflow_up ();
  overflow_inv ();

  emin = mpfr_get_emin ();
  emax = mpfr_get_emax ();
  set_emin (MPFR_EMIN_MIN);
  set_emax (MPFR_EMAX_MAX);
  if (mpfr_get_emin () != emin || mpfr_get_emax () != emax)
    {
      ext = 1;
      tst ();
      underflow_up ();
      overflow_inv ();
      set_emin (emin);
      set_emax (emax);
    }
}
开发者ID:BreakawayConsulting,项目名称:mpfr,代码行数:24,代码来源:tpow_all.c


示例18: check_underflow

static void
check_underflow (void)
{
  mpfr_t a;
  mp_exp_t emin, emax;
  int res;

  mpfr_init (a);

  /* Check underflow */
  emin = mpfr_get_emin ();
  set_emin (-20);
  res = mpfr_set_str (a, "0.00000000001", 10, GMP_RNDZ);
  if (!MPFR_IS_ZERO (a))
    {
      printf("ERROR for mpfr_set_str (a, \"0.00000000001\", 10, GMP_RNDN)\n"
             " with emin=-20\n"
             "res=%d\n", res);
      mpfr_dump (a);
      exit (1);
    }
  set_emin (emin);

  /* check overflow */
  emax = mpfr_get_emax ();
  set_emax (1073741823); /* 2^30-1 */
  mpfr_set_str (a, "2E1000000000", 10, GMP_RNDN);
  if (!mpfr_inf_p (a) || mpfr_sgn (a) < 0)
    {
      printf("ERROR for mpfr_set_str (a, \"2E1000000000\", 10, GMP_RNDN);\n");
      exit (1);
    }
  set_emax (emax);

  mpfr_clear (a);
}
开发者ID:STAR111,项目名称:GCC_parser,代码行数:36,代码来源:tset_str.c


示例19: main

int
main (int argc, char *argv[])
{
  mpfr_t x, y;
  mpfr_exp_t emin, emax;

  tests_start_mpfr ();

  special_overflow ();
  emax_m_eps ();
  exp_range ();

  mpfr_init (x);
  mpfr_init (y);

  mpfr_set_ui (x, 4, MPFR_RNDN);
  mpfr_exp2 (y, x, MPFR_RNDN);
  if (mpfr_cmp_ui (y, 16) != 0)
    {
      printf ("Error for 2^4, MPFR_RNDN\n");
      exit (1);
    }
  mpfr_exp2 (y, x, MPFR_RNDD);
  if (mpfr_cmp_ui (y, 16) != 0)
    {
      printf ("Error for 2^4, MPFR_RNDD\n");
      exit (1);
    }
  mpfr_exp2 (y, x, MPFR_RNDU);
  if (mpfr_cmp_ui (y, 16) != 0)
    {
      printf ("Error for 2^4, MPFR_RNDU\n");
      exit (1);
    }

  mpfr_set_si (x, -4, MPFR_RNDN);
  mpfr_exp2 (y, x, MPFR_RNDN);
  if (mpfr_cmp_ui_2exp (y, 1, -4) != 0)
    {
      printf ("Error for 2^(-4), MPFR_RNDN\n");
      exit (1);
    }
  mpfr_exp2 (y, x, MPFR_RNDD);
  if (mpfr_cmp_ui_2exp (y, 1, -4) != 0)
    {
      printf ("Error for 2^(-4), MPFR_RNDD\n");
      exit (1);
    }
  mpfr_exp2 (y, x, MPFR_RNDU);
  if (mpfr_cmp_ui_2exp (y, 1, -4) != 0)
    {
      printf ("Error for 2^(-4), MPFR_RNDU\n");
      exit (1);
    }

  mpfr_set_prec (x, 53);
  mpfr_set_prec (y, 53);
  mpfr_set_str (x, /*-1683977482443233.0 / 2199023255552.0*/
                "-7.6578429909351734750089235603809357e2", 10, MPFR_RNDN);
  mpfr_exp2 (y, x, MPFR_RNDN);
  if (mpfr_cmp_str1 (y, "2.991959870867646566478e-231"))
    {
      printf ("Error for x=-1683977482443233/2^41\n");
      exit (1);
    }

  mpfr_set_prec (x, 10);
  mpfr_set_prec (y, 10);
  /* save emin */
  emin = mpfr_get_emin ();
  set_emin (-10);
  mpfr_set_si (x, -12, MPFR_RNDN);
  mpfr_exp2 (y, x, MPFR_RNDN);
  if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
    {
      printf ("Error for x=emin-2, RNDN\n");
      printf ("Expected +0\n");
      printf ("Got      "); mpfr_print_binary (y); puts ("");
      exit (1);
    }
  /* restore emin */
  set_emin (emin);

  /* save emax */
  emax = mpfr_get_emax ();
  set_emax (10);
  mpfr_set_ui (x, 11, MPFR_RNDN);
  mpfr_exp2 (y, x, MPFR_RNDN);
  if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
    {
      printf ("Error for x=emax+1, RNDN\n");
      exit (1);
    }
  /* restore emax */
  set_emax (emax);

  MPFR_SET_INF(x);
  MPFR_SET_POS(x);
  mpfr_exp2 (y, x, MPFR_RNDN);
  if(!MPFR_IS_INF(y))
//.........这里部分代码省略.........
开发者ID:sudheesh001,项目名称:SEC-LAB,代码行数:101,代码来源:texp2.c


示例20: overflowed_sec0

static void
overflowed_sec0 (void)
{
  mpfr_t x, y;
  int emax, i, inex, rnd, err = 0;
  mpfr_exp_t old_emax;

  old_emax = mpfr_get_emax ();

  mpfr_init2 (x, 8);
  mpfr_init2 (y, 8);

  for (emax = -1; emax <= 0; emax++)
    {
      mpfr_set_ui_2exp (y, 1, emax, MPFR_RNDN);
      mpfr_nextbelow (y);
      set_emax (emax);  /* 1 is not representable. */
      for (i = -1; i <= 1; i++)
        RND_LOOP (rnd)
          {
            mpfr_set_si_2exp (x, i, -512 * ABS (i), MPFR_RNDN);
            mpfr_clear_flags ();
            inex = mpfr_sec (x, x, (mpfr_rnd_t) rnd);
            if (! mpfr_overflow_p ())
              {
                printf ("Error in overflowed_sec0 (i = %d, rnd = %s):\n"
                        "  The overflow flag is not set.\n",
                        i, mpfr_print_rnd_mode ((mpfr_rnd_t) rnd));
                err = 1;
              }
            if (rnd == MPFR_RNDZ || rnd == MPFR_RNDD)
              {
                if (inex >= 0)
                  {
                    printf ("Error in overflowed_sec0 (i = %d, rnd = %s):\n"
                            "  The inexact value must be negative.\n",
                            i, mpfr_print_rnd_mode ((mpfr_rnd_t) rnd));
                    err = 1;
                  }
                if (! mpfr_equal_p (x, y))
                  {
                    printf ("Error in overflowed_sec0 (i = %d, rnd = %s):\n"
                            "  Got ", i, mpfr_print_rnd_mode ((mpfr_rnd_t) rnd));
                    mpfr_print_binary (x);
                    printf (" instead of 0.11111111E%d.\n", emax);
                    err = 1;
                  }
              }
            else
              {
                if (inex <= 0)
                  {
                    printf ("Error in overflowed_sec0 (i = %d, rnd = %s):\n"
                            "  The inexact value must be positive.\n",
                            i, mpfr_print_rnd_mode ((mpfr_rnd_t) rnd));
                    err = 1;
                  }
                if (! (mpfr_inf_p (x) && MPFR_SIGN (x) > 0))
                  {
                    printf ("Error in overflowed_sec0 (i = %d, rnd = %s):\n"
                            "  Got ", i, mpfr_print_rnd_mode ((mpfr_rnd_t) rnd));
                    mpfr_print_binary (x);
                    printf (" instead of +Inf.\n");
                    err = 1;
                  }
              }
          }
      set_emax (old_emax);
    }

  if (err)
    exit (1);
  mpfr_clear (x);
  mpfr_clear (y);
}
开发者ID:epowers,项目名称:mpfr,代码行数:75,代码来源:tsec.c



注:本文中的set_emax函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ set_emin函数代码示例发布时间:2022-05-30
下一篇:
C++ set_dst_uri函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap