这篇教程C++ tests_start_mpfr函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tests_start_mpfr函数的典型用法代码示例。如果您正苦于以下问题:C++ tests_start_mpfr函数的具体用法?C++ tests_start_mpfr怎么用?C++ tests_start_mpfr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tests_start_mpfr函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainintmain (void){ int j; mpfr_t x; tests_start_mpfr (); special (); mpfr_init2 (x, 500); for (j = 0; j < 500; j++) { mpfr_urandomb (x, RANDS); teq (x); } mpfr_clear (x); tests_end_mpfr (); return 0;}
开发者ID:BreakawayConsulting,项目名称:mpfr,代码行数:23,
示例2: mainintmain (int argc, char* argv[]){ tests_start_mpfr (); check_nans (); check_large (); check4 ("2.0", "1.0", MPFR_RNDN, "1.45679103104690677029"); check4 ("6.0", "4.0", MPFR_RNDN, "4.94936087247260925182"); check4 ("62.0", "61.0", MPFR_RNDN, "6.14989837188450749750e+01"); check4 ("0.5", "1.0", MPFR_RNDN, "7.28395515523453385143e-01"); check4 ("1.0", "2.0", MPFR_RNDN, "1.45679103104690677029"); check4 ("234375765.0", "234375000.0", MPFR_RNDN, "2.3437538249984395504e8"); check4 ("8.0", "1.0", MPFR_RNDU, "3.615756177597362786"); check4 ("1.0", "44.0", MPFR_RNDU, "1.33658354512981247808e1"); check4 ("1.0", "3.7252902984619140625e-9", MPFR_RNDU, "7.55393356971199025907e-02"); test_generic (2, 300, 17); tests_end_mpfr (); return 0;}
开发者ID:119,项目名称:aircam-openwrt,代码行数:23,
示例3: mainintmain (int argc, char* argv[]){ tests_start_mpfr (); check_special (); check_large (); check4 ("2.0", "1.0", MPFR_RNDN, "1.456791031046906869", -1); check4 ("6.0", "4.0", MPFR_RNDN, "4.949360872472608925", 1); check4 ("62.0", "61.0", MPFR_RNDN, "61.498983718845075902", -1); check4 ("0.5", "1.0", MPFR_RNDN, "0.72839551552345343459", -1); check4 ("1.0", "2.0", MPFR_RNDN, "1.456791031046906869", -1); check4 ("234375765.0", "234375000.0", MPFR_RNDN, "234375382.49984394025", 1); check4 ("8.0", "1.0", MPFR_RNDU, "3.61575617759736274873", 1); check4 ("1.0", "44.0", MPFR_RNDU, "13.3658354512981243907", 1); check4 ("1.0", "3.7252902984619140625e-9", MPFR_RNDU, "0.07553933569711989657765", 1); test_generic (2, 300, 17); tests_end_mpfr (); return 0;}
开发者ID:Canar,项目名称:mpfr,代码行数:23,
示例4: mainintmain (int argc, char *argv[]){ mpfr_prec_t p; unsigned k; tests_start_mpfr (); check_nans (); special (); for (p=2; p<100; p++) for (k=0; k<100; k++) check_two_sum (p); check(1196426492, "1.4218093058435347e-3", MPFR_RNDN, "1.1964264919985781e9"); check(1092583421, "-1.0880649218158844e9", MPFR_RNDN, "2.1806483428158845901e9"); check(948002822, "1.22191250737771397120e+20", MPFR_RNDN, "-1.2219125073682338611e20"); check(832100416, "4.68311314939691330000e-215", MPFR_RNDD, "8.3210041599999988079e8"); check(1976245324, "1.25296395864546893357e+232", MPFR_RNDZ, "-1.2529639586454686577e232"); check(2128997392, "-1.08496826129284207724e+187", MPFR_RNDU, "1.0849682612928422704e187"); check(293607738, "-1.9967571564050541e-5", MPFR_RNDU, "2.9360773800002003e8"); check(354270183, "2.9469161763489528e3", MPFR_RNDN, "3.5426723608382362e8"); check_neg (); tests_end_mpfr (); return 0;}
开发者ID:Kirija,项目名称:XPIR,代码行数:37,
示例5: mainintmain (int argc, char *argv[]){ long nbtests; mpfr_prec_t prec; int verbose = 0; tests_start_mpfr (); if (argc > 1) verbose = 1; nbtests = 10000; if (argc > 1) { long a = atol(argv[1]); if (a != 0) nbtests = a; } if (argc <= 2) prec = 1000; else prec = atol(argv[2]); test_urandomb (nbtests, prec, verbose); if (argc == 1) /* check also small precision */ { test_urandomb (nbtests, 2, 0); } bug20100914 (); tests_end_mpfr (); return 0;}
开发者ID:axDev-toolchain,项目名称:mpfr,代码行数:37,
示例6: mainintmain (int argc, char **argv){ char *locale; tests_start_mpfr ();#if defined(HAVE_LOCALE_H) && defined(HAVE_SETLOCALE) /* currently, we just check with 'C' locale */ locale = setlocale (LC_ALL, "C");#endif bug20111102 (); native_types (); hexadecimal (); binary (); decimal (); mixed (); check_emax ();#if defined(HAVE_LOCALE_H) && defined(HAVE_SETLOCALE) locale_da_DK (); setlocale (LC_ALL, locale);#endif if (getenv ("MPFR_CHECK_LIBC_PRINTF")) { /* check against libc */ random_double (); bug20081214 (); bug20080610 (); } tests_end_mpfr (); return 0;}
开发者ID:SESA,项目名称:EbbRT-mpfr,代码行数:37,
示例7: mainintmain (int argc, char *argv[]){ tests_start_mpfr (); special_overflow (); special (); special_atan2 (); smallvals_atan2 (); atan2_bug_20071003 (); atan2_different_prec (); reduced_expo_range (); test_generic_atan (2, 200, 17); test_generic_atan2 (2, 200, 17); test_generic_atan2_neg (2, 200, 17); data_check ("data/atan", mpfr_atan, "mpfr_atan"); bad_cases (mpfr_atan, mpfr_tan, "mpfr_atan", 256, -40, 1, 4, 128, 800, 40); atan2_pow_of_2 (); tests_end_mpfr (); return 0;}
开发者ID:Canar,项目名称:mpfr,代码行数:24,
示例8: mainintmain (void){ mpfr_t a, b, c; long large_prec; tests_start_mpfr (); mpfr_inits (a, b, c, (mpfr_ptr) 0); mpfr_clears (a, b, c, (mpfr_ptr) 0); mpfr_inits2 (200, a, b, c, (mpfr_ptr) 0); mpfr_clears (a, b, c, (mpfr_ptr) 0); /* test for precision 2^31-1, see https://gforge.inria.fr/tracker/index.php?func=detail&aid=13918 */ large_prec = 2147483647; if (getenv ("MPFR_CHECK_LARGEMEM") != NULL) { /* We assume that the precision won't be increased internally. */ if (large_prec > MPFR_PREC_MAX) large_prec = MPFR_PREC_MAX; mpfr_inits2 (large_prec, a, b, (mpfr_ptr) 0); mpfr_set_ui (a, 17, MPFR_RNDN); mpfr_set (b, a, MPFR_RNDN); if (mpfr_get_ui (a, MPFR_RNDN) != 17) { printf ("Error in mpfr_init2 with precision 2^31-1/n"); exit (1); } mpfr_clears (a, b, (mpfr_ptr) 0); } tests_end_mpfr (); return 0;}
开发者ID:sudheesh001,项目名称:SEC-LAB,代码行数:36,
示例9: mainintmain (void){ mpfr_t u, v; tests_start_mpfr (); mpfr_init2 (u, 24); mpfr_init2 (v, 53); mpfr_set_ui (u, 16777215, MPFR_RNDN); /* 2^24 - 1 */ mpfr_set_str1 (v, "9007199254740991.0"); /* 2^53 - 1 */ mpfr_swap (u, v); mpfr_swap (u, v); if (mpfr_cmp_ui (u, 16777215) || mpfr_cmp_str1 (v, "9007199254740991.0")) { printf ("Error in mpfr_swap/n"); exit (1); } mpfr_clear (u); mpfr_clear (v); tests_end_mpfr (); return 0;}
开发者ID:SESA,项目名称:EbbRT-mpfr,代码行数:24,
示例10: mainintmain (int argc, char *argv[]){ tests_start_mpfr (); check_nan (); check_inexact (); check(948002822, "1.22191250737771397120e+20", MPFR_RNDN, "7.758352715731357946e-12"); check(1976245324, "1.25296395864546893357e+232", MPFR_RNDZ, "1.5772563211925444801e-223"); check(740454110, "2.11496253355831863313e+183", MPFR_RNDZ, "3.5010270784996976041e-175"); check(1690540942, "1.28278599852446657468e-276", MPFR_RNDU, "1.3178666932321966062e285"); check(1476599377, "-2.14191393656148625995e+305", MPFR_RNDD, "-6.8938315017943889615e-297"); /* inv is for 1/x */ data_check ("data/inv", mpfr_inv, "mpfr_ui_div(1,x)"); tests_end_mpfr (); return 0;}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:24,
示例11: mainintmain (int argc, char *argv[]){ long nbtests; int verbose; tests_start_mpfr (); verbose = 0; nbtests = 10; if (argc > 1) { long a = atol (argv[1]); verbose = 1; if (a != 0) nbtests = a; } test_grandom (nbtests, 420, MPFR_RNDN, verbose); test_special (2); test_special (42000); tests_end_mpfr (); return 0;}
开发者ID:epowers,项目名称:mpfr,代码行数:24,
示例12: mainintmain (void){ mpfr_t x; intmax_t j; tests_start_mpfr (); mpfr_init_set_ui (x, 1, MPFR_RNDN); j = mpfr_get_uj (x, MPFR_RNDN); mpfr_clear (x); if (j != 1) {#ifdef MPFR_PRINTF_MAXLM printf ("Error: got %" MPFR_PRINTF_MAXLM "d instead of 1./n", j);#else printf ("Error: did not get 1./n");#endif exit (1); } tests_end_mpfr (); return 0;}
开发者ID:BrianGladman,项目名称:mpfr,代码行数:24,
示例13: mainintmain (void){ mpfr_prec_t prec; mpfr_t x, y; intmax_t s; uintmax_t u; tests_start_mpfr (); for (u = MPFR_UINTMAX_MAX, prec = 0; u != 0; u /= 2, prec++) { } mpfr_init2 (x, prec + 4); mpfr_init2 (y, prec + 4); mpfr_set_ui (x, 0, MPFR_RNDN); check_sj (0, x); check_uj (0, x); mpfr_set_ui (x, 1, MPFR_RNDN); check_sj (1, x); check_uj (1, x); mpfr_neg (x, x, MPFR_RNDN); check_sj (-1, x); mpfr_set_si_2exp (x, 1, prec, MPFR_RNDN); mpfr_sub_ui (x, x, 1, MPFR_RNDN); /* UINTMAX_MAX */ mpfr_div_ui (y, x, 2, MPFR_RNDZ); mpfr_trunc (y, y); /* INTMAX_MAX */ for (s = MPFR_INTMAX_MAX; s != 0; s /= 17) { check_sj (s, y); mpfr_div_ui (y, y, 17, MPFR_RNDZ); mpfr_trunc (y, y); } mpfr_div_ui (y, x, 2, MPFR_RNDZ); mpfr_trunc (y, y); /* INTMAX_MAX */ mpfr_neg (y, y, MPFR_RNDN); if (MPFR_INTMAX_MIN + MPFR_INTMAX_MAX != 0) mpfr_sub_ui (y, y, 1, MPFR_RNDN); /* INTMAX_MIN */ for (s = MPFR_INTMAX_MIN; s != 0; s /= 17) { check_sj (s, y); mpfr_div_ui (y, y, 17, MPFR_RNDZ); mpfr_trunc (y, y); } for (u = MPFR_UINTMAX_MAX; u != 0; u /= 17) { check_uj (u, x); mpfr_div_ui (x, x, 17, MPFR_RNDZ); mpfr_trunc (x, x); } mpfr_clear (x); mpfr_clear (y); check_erange (); tests_end_mpfr (); return 0;}
开发者ID:BreakawayConsulting,项目名称:mpfr,代码行数:66,
示例14: mainintmain (int argc, char *argv[]){ mpfr_t x, y; int inex; tests_start_mpfr (); mpfr_init (x); mpfr_init (y); /* special values */ mpfr_set_nan (x); mpfr_j0 (y, x, MPFR_RNDN); MPFR_ASSERTN(mpfr_nan_p (y)); mpfr_set_inf (x, 1); /* +Inf */ mpfr_j0 (y, x, MPFR_RNDN); MPFR_ASSERTN(mpfr_cmp_ui (y, 0) == 0 && MPFR_IS_POS (y)); mpfr_set_inf (x, -1); /* -Inf */ mpfr_j0 (y, x, MPFR_RNDN); MPFR_ASSERTN(mpfr_cmp_ui (y, 0) == 0 && MPFR_IS_POS (y)); mpfr_set_ui (x, 0, MPFR_RNDN); /* +0 */ mpfr_j0 (y, x, MPFR_RNDN); MPFR_ASSERTN(mpfr_cmp_ui (y, 1) == 0); /* j0(+0)=1 */ mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_neg (x, x, MPFR_RNDN); /* -0 */ mpfr_j0 (y, x, MPFR_RNDN); MPFR_ASSERTN(mpfr_cmp_ui (y, 1) == 0); /* j0(-0)=1 */ mpfr_set_prec (x, 53); mpfr_set_prec (y, 53); mpfr_set_ui (x, 1, MPFR_RNDN); mpfr_j0 (y, x, MPFR_RNDN); mpfr_set_str_binary (x, "0.1100001111100011111111101101111010111101110001111"); if (mpfr_cmp (x, y)) { printf ("Error in mpfr_j0 for x=1, rnd=MPFR_RNDN/n"); printf ("Expected "); mpfr_dump (x); printf ("Got "); mpfr_dump (y); exit (1); } mpfr_set_si (x, -1, MPFR_RNDN); mpfr_j0 (y, x, MPFR_RNDN); mpfr_set_str_binary (x, "0.1100001111100011111111101101111010111101110001111"); if (mpfr_cmp (x, y)) { printf ("Error in mpfr_j0 for x=-1, rnd=MPFR_RNDN/n"); printf ("Expected "); mpfr_dump (x); printf ("Got "); mpfr_dump (y); exit (1); } /* Bug reported on 2007-07-03 by Sisyphus (assertion failed in r4619) */ mpfr_set_si (x, 70000, MPFR_RNDN); mpfr_j0 (y, x, MPFR_RNDN); /* Bug reported by Kevin Rauch on 27 Oct 2007 */ mpfr_set_prec (x, 7); mpfr_set_prec (y, 7); mpfr_set_si (x, -100, MPFR_RNDN); mpfr_j0 (y, x, MPFR_RNDN); MPFR_ASSERTN (! mpfr_nan_p (y) && mpfr_cmp_ui_2exp (y, 41, -11) == 0); /* Case for which s = 0 in mpfr_jn */ mpfr_set_prec (x, 44); mpfr_set_prec (y, 44); mpfr_set_si (x, 2, MPFR_RNDN); mpfr_clear_flags (); inex = mpfr_j0 (y, x, MPFR_RNDN); MPFR_ASSERTN (__gmpfr_flags == MPFR_FLAGS_INEXACT); mpfr_set_str (x, "0x.e5439fd9267p-2", 0, MPFR_RNDN); if (! mpfr_equal_p (y, x)) { printf ("Error on 2:/n"); printf ("Expected "); mpfr_dump (x); printf ("Got "); mpfr_dump (y); exit (1); } if (inex >= 0) { printf ("Bad ternary value on 2: expected negative, got %d/n", inex); exit (1); } mpfr_clear (x); mpfr_clear (y); test_generic (2, 100, 10); data_check ("data/j0", mpfr_j0, "mpfr_j0"); tests_end_mpfr ();//.........这里部分代码省略.........
开发者ID:epowers,项目名称:mpfr,代码行数:101,
示例15: mainintmain (void){ int j, k; mpfr_t x, y, z, t, y2, z2, t2; tests_start_mpfr (); mpfr_inits2 (SIZEX, x, y, z, t, y2, z2, t2, (mpfr_ptr) 0); mpfr_set_str1 (x, "0.5"); mpfr_ceil(y, x); if (mpfr_cmp_ui (y, 1)) { printf ("Error in mpfr_ceil for x=0.5: expected 1.0, got "); mpfr_print_binary(y); putchar('/n'); exit (1); } mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_ceil(y, x); if (mpfr_cmp_ui(y,0)) { printf ("Error in mpfr_ceil for x=0.0: expected 0.0, got "); mpfr_print_binary(y); putchar('/n'); exit (1); } mpfr_set_ui (x, 1, MPFR_RNDN); mpfr_ceil(y, x); if (mpfr_cmp_ui(y,1)) { printf ("Error in mpfr_ceil for x=1.0: expected 1.0, got "); mpfr_print_binary(y); putchar('/n'); exit (1); } for (j=0;j<1000;j++) { mpfr_urandomb (x, RANDS); MPFR_EXP (x) = 2; for (k = 2; k <= SIZEX; k++) { mpfr_set_prec(y, k); mpfr_set_prec(y2, k); mpfr_set_prec(z, k); mpfr_set_prec(z2, k); mpfr_set_prec(t, k); mpfr_set_prec(t2, k); mpfr_floor(y, x); mpfr_set(y2, x, MPFR_RNDD); mpfr_trunc(z, x); mpfr_set(z2, x, MPFR_RNDZ); mpfr_ceil(t, x); mpfr_set(t2, x, MPFR_RNDU); if (!mpfr_eq(y, y2, k)) { printf("Error in floor, x = "); mpfr_print_binary(x); printf("/n"); printf("floor(x) = "); mpfr_print_binary(y); printf("/n"); printf("round(x, RNDD) = "); mpfr_print_binary(y2); printf("/n"); exit(1); } if (!mpfr_eq(z, z2, k)) { printf("Error in trunc, x = "); mpfr_print_binary(x); printf("/n"); printf("trunc(x) = "); mpfr_print_binary(z); printf("/n"); printf("round(x, RNDZ) = "); mpfr_print_binary(z2); printf("/n"); exit(1); } if (!mpfr_eq(y, y2, k)) { printf("Error in ceil, x = "); mpfr_print_binary(x); printf("/n"); printf("ceil(x) = "); mpfr_print_binary(t); printf("/n"); printf("round(x, RNDU) = "); mpfr_print_binary(t2); printf("/n"); exit(1); } MPFR_EXP(x)++; } } mpfr_clears (x, y, z, t, y2, z2, t2, (mpfr_ptr) 0);//.........这里部分代码省略.........
开发者ID:Kirija,项目名称:XPIR,代码行数:101,
示例16: mainintmain (int argc, char *argv[]){ mpfr_t x, y; tests_start_mpfr (); mpfr_init (x); mpfr_init (y); /* special values */ mpfr_set_nan (x); mpfr_y0 (y, x, MPFR_RNDN); MPFR_ASSERTN(mpfr_nan_p (y)); mpfr_set_inf (x, 1); /* +Inf */ mpfr_y0 (y, x, MPFR_RNDN); MPFR_ASSERTN(mpfr_cmp_ui (y, 0) == 0 && MPFR_IS_POS (y)); mpfr_set_inf (x, -1); /* -Inf */ mpfr_y0 (y, x, MPFR_RNDN); MPFR_ASSERTN(mpfr_nan_p (y)); mpfr_set_ui (x, 0, MPFR_RNDN); /* +0 */ mpfr_y0 (y, x, MPFR_RNDN); MPFR_ASSERTN(mpfr_inf_p (y) && MPFR_IS_NEG (y)); /* y0(+0)=-Inf */ mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_neg (x, x, MPFR_RNDN); /* -0 */ mpfr_y0 (y, x, MPFR_RNDN); MPFR_ASSERTN(mpfr_inf_p (y) && MPFR_IS_NEG (y)); /* y0(-0)=-Inf */ mpfr_set_prec (x, 53); mpfr_set_prec (y, 53); mpfr_set_ui (x, 1, MPFR_RNDN); mpfr_y0 (y, x, MPFR_RNDN); mpfr_set_str_binary (x, "0.00010110100110000000001000100110111100110101100011011111"); if (mpfr_cmp (x, y)) { printf ("Error in mpfr_y0 for x=1, rnd=MPFR_RNDN/n"); printf ("Expected "); mpfr_dump (x); printf ("Got "); mpfr_dump (y); exit (1); } mpfr_set_si (x, -1, MPFR_RNDN); mpfr_y0 (y, x, MPFR_RNDN); if (!mpfr_nan_p (y)) { printf ("Error in mpfr_y0 for x=-1, rnd=MPFR_RNDN/n"); printf ("Expected NaN/n"); printf ("Got "); mpfr_dump (y); exit (1); } mpfr_clear (x); mpfr_clear (y); test_generic (2, 100, 1); data_check ("data/y0", mpfr_y0, "mpfr_y0"); tests_end_mpfr (); return 0;}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:67,
示例17: mainintmain (int argc, char *argv[]){ mpfr_t x, y; int inex; tests_start_mpfr (); special_overflow (); check_nans (); mpfr_init (x); mpfr_init (y); mpfr_set_prec (x, 53); mpfr_set_prec (y, 2); mpfr_set_str (x, "9.81333845856942e-1", 10, MPFR_RNDN); test_cos (y, x, MPFR_RNDN); mpfr_set_prec (x, 30); mpfr_set_prec (y, 30); mpfr_set_str_binary (x, "1.00001010001101110010100010101e-1"); test_cos (y, x, MPFR_RNDU); mpfr_set_str_binary (x, "1.10111100010101011110101010100e-1"); if (mpfr_cmp (y, x)) { printf ("Error for prec=30, rnd=MPFR_RNDU/n"); printf ("expected "); mpfr_print_binary (x); puts (""); printf (" got "); mpfr_print_binary (y); puts (""); exit (1); } mpfr_set_prec (x, 59); mpfr_set_prec (y, 59); mpfr_set_str_binary (x, "1.01101011101111010011111110111111111011011101100111100011e-3"); test_cos (y, x, MPFR_RNDU); mpfr_set_str_binary (x, "1.1111011111110010001001001011100111101110100010000010010011e-1"); if (mpfr_cmp (y, x)) { printf ("Error for prec=59, rnd=MPFR_RNDU/n"); printf ("expected "); mpfr_print_binary (x); puts (""); printf (" got "); mpfr_print_binary (y); puts (""); exit (1); } mpfr_set_prec (x, 5); mpfr_set_prec (y, 5); mpfr_set_str_binary (x, "1.1100e-2"); test_cos (y, x, MPFR_RNDD); mpfr_set_str_binary (x, "1.1100e-1"); if (mpfr_cmp (y, x)) { printf ("Error for x=1.1100e-2, rnd=MPFR_RNDD/n"); printf ("expected 1.1100e-1, got "); mpfr_print_binary (y); puts (""); exit (1); } mpfr_set_prec (x, 32); mpfr_set_prec (y, 32); mpfr_set_str_binary (x, "0.10001000001001011000100001E-6"); mpfr_set_str_binary (y, "0.1111111111111101101111001100001"); test_cos (x, x, MPFR_RNDN); if (mpfr_cmp (x, y)) { printf ("Error for prec=32 (1)/n"); exit (1); } mpfr_set_str_binary (x, "-0.1101011110111100111010011001011E-1"); mpfr_set_str_binary (y, "0.11101001100110111011011010100011"); test_cos (x, x, MPFR_RNDN); if (mpfr_cmp (x, y)) { printf ("Error for prec=32 (2)/n"); exit (1); } /* huge argument reduction */ mpfr_set_str_binary (x, "0.10000010000001101011101111001011E40"); mpfr_set_str_binary (y, "0.10011000001111010000101011001011E-1"); test_cos (x, x, MPFR_RNDN); if (mpfr_cmp (x, y)) { printf ("Error for prec=32 (3)/n"); exit (1); } mpfr_set_prec (x, 3); mpfr_set_prec (y, 3); mpfr_set_str_binary (x, "0.110E60"); inex = mpfr_cos (y, x, MPFR_RNDD); MPFR_ASSERTN(inex < 0); /* worst case from PhD thesis of Vincent Lefe`vre: x=8980155785351021/2^54 */ check53 ("4.984987858808754279e-1", "8.783012931285841817e-1", MPFR_RNDN); check53 ("4.984987858808754279e-1", "8.783012931285840707e-1", MPFR_RNDD); check53 ("4.984987858808754279e-1", "8.783012931285840707e-1", MPFR_RNDZ); check53 ("4.984987858808754279e-1", "8.783012931285841817e-1", MPFR_RNDU); check53 ("1.00031274099908640274", "0.540039116973283217504", MPFR_RNDN);//.........这里部分代码省略.........
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:101,
示例18: mainintmain (int argc, char *argv[]){ mpfr_t x, y; unsigned long int n; tests_start_mpfr (); mpfr_init (x); mpfr_init (y); n = randlimb (); MPFR_SET_INF(x); mpfr_ui_pow (y, n, x, MPFR_RNDN); if(!MPFR_IS_INF(y)) { printf ("evaluation of function in INF does not return INF/n"); exit (1); } MPFR_CHANGE_SIGN(x); mpfr_ui_pow (y, n, x, MPFR_RNDN); if(!MPFR_IS_ZERO(y)) { printf ("evaluation of function in -INF does not return 0"); exit (1); } MPFR_SET_NAN(x); mpfr_ui_pow (y, n, x, MPFR_RNDN); if(!MPFR_IS_NAN(y)) { printf ("evaluation of function in NAN does not return NAN"); exit (1); } test1 (); { mpfr_t z, t; mpfr_prec_t prec; mpfr_rnd_t rnd; unsigned int n; mpfr_prec_t p0=2, p1=100; unsigned int N=20; mpfr_init2 (z, 38); mpfr_init2 (t, 6); /* check exact power */ mpfr_set_str_binary (t, "0.110000E5"); mpfr_ui_pow (z, 3, t, MPFR_RNDN); mpfr_set_prec (x, 2); mpfr_set_prec (y, 2); mpfr_set_str (x, "-0.5", 10, MPFR_RNDZ); mpfr_ui_pow (y, 4, x, MPFR_RNDD); if (mpfr_cmp_ui_2exp(y, 1, -1)) { fprintf (stderr, "Error for 4^(-0.5), prec=2, MPFR_RNDD/n"); fprintf (stderr, "expected 0.5, got "); mpfr_out_str (stderr, 2, 0, y, MPFR_RNDN); fprintf (stderr, "/n"); exit (1); } /* problem found by Kevin on spe175.testdrive.compaq.com (03 Sep 2003), ia64 under HP-UX */ mpfr_set_prec (x, 2); mpfr_set_prec (y, 2); mpfr_set_str (x, "0.5", 10, MPFR_RNDN); mpfr_ui_pow (y, 398441521, x, MPFR_RNDN); if (mpfr_cmp_ui_2exp(y, 1, 14)) { fprintf (stderr, "Error for 398441521^(0.5), prec=2, MPFR_RNDN/n"); fprintf (stderr, "expected 1.0e14, got "); mpfr_out_str (stderr, 2, 0, y, MPFR_RNDN); fprintf (stderr, "/n"); exit (1); } mpfr_clear (z); mpfr_clear (t); mpfr_set_prec (x, 2); mpfr_set_str (x, "0.5", 10, MPFR_RNDN); check1 (x, 2, 398441521, MPFR_RNDN); /* 398441521 = 19961^2 */ /* generic test */ for (prec = p0; prec <= p1; prec++) { mpfr_set_prec (x, prec); for (n=0; n<N; n++) { int nt; nt = randlimb () & INT_MAX; mpfr_urandomb (x, RANDS); rnd = RND_RAND ();//.........这里部分代码省略.........
开发者ID:michalkonecny,项目名称:haskell-mpfr,代码行数:101,
示例19: mainintmain (int argc, char *argv[]){ unsigned int prec, err, yprec, n, k, zeros; int rnd; mpfr_t x, y, z, t; int inexact; tests_start_mpfr (); special (); test_int (); mpfr_init (x); mpfr_init (y); mpfr_init (z); mpfr_init (t); mpfr_fac_ui (y, 0, GMP_RNDN); if (mpfr_cmp_ui (y, 1)) { printf ("mpfr_fac_ui(0) does not give 1/n"); exit (1); } for (prec = 2; prec <= 100; prec++) { mpfr_set_prec (x, prec); mpfr_set_prec (z, prec); mpfr_set_prec (t, prec); yprec = prec + 10; 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); } } } }
开发者ID:STAR111,项目名称:GCC_parser,代码行数:86,
示例20: mainintmain (int argc, char *argv[]){ int i, N=10000, p; mpfr_rnd_t rnd; double d; tests_start_mpfr (); /* with no argument: prints to /dev/null, tout_str N: prints N tests to stdout */ if (argc == 1) { fout = fopen ("/dev/null", "w"); /* If we failed to open this device, try with a dummy file */ if (fout == NULL) fout = fopen ("mpfrtest.txt", "w"); } else { fout = stdout; N = atoi (argv[1]); } if (fout == NULL) { printf ("Can't open /dev/null or stdout/n"); exit (1); } special (); check (-1.37247529013405550000e+15, MPFR_RNDN, 7); check (-1.5674376729569697500e+15, MPFR_RNDN, 19); check (-5.71262771772792640000e-79, MPFR_RNDU, 16); check (DBL_NEG_ZERO, MPFR_RNDU, 7); check (-4.5306392613572974756e-308, MPFR_RNDN, 8); check (-6.7265890111403371523e-165, MPFR_RNDN, 4); check (-1.3242553591261807653e+156, MPFR_RNDN, 16); check (-6.606499965302424244461355e233, MPFR_RNDN, 10); check4 (1.0, MPFR_RNDN, 10, 120); check (1.0, MPFR_RNDU, 10); check (4.059650008e-83, MPFR_RNDN, 10); check (-7.4, MPFR_RNDN, 10); check (0.997, MPFR_RNDN, 10); check (-4.53063926135729747564e-308, MPFR_RNDN, 10); check (2.14478198760196000000e+16, MPFR_RNDN, 10); check (7.02293374921793516813e-84, MPFR_RNDN, 10); /* random tests */ for (i=0;i<N;i++) { do { d = DBL_RAND (); }#ifdef HAVE_DENORMS while (0);#else while (ABS(d) < DBL_MIN);#endif rnd = RND_RAND (); p = 2 + randlimb () % 61; check (d, rnd, p); } fclose (fout); tests_end_mpfr (); return 0;}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:71,
示例21: mainintmain (void){ mpfr_t x, y, z; int i, j, k; tests_start_mpfr (); mpfr_init (x); mpfr_init (y); mpfr_init (z); for (i = 0; i <= 1; i++) for (j = 0; j <= 1; j++) for (k = 0; k <= 5; k++) { mpfr_set_nan (x); i ? MPFR_SET_NEG (x) : MPFR_SET_POS (x); mpfr_set_nan (y); j ? MPFR_SET_NEG (y) : MPFR_SET_POS (y); copysign_variant (z, x, y, MPFR_RNDN, k); if (MPFR_SIGN (z) != MPFR_SIGN (y) || !mpfr_nanflag_p ()) { printf ("Error in mpfr_copysign (%cNaN, %cNaN)/n", i ? '-' : '+', j ? '-' : '+'); exit (1); } mpfr_set_si (x, i ? -1250 : 1250, MPFR_RNDN); mpfr_set_nan (y); j ? MPFR_SET_NEG (y) : MPFR_SET_POS (y); copysign_variant (z, x, y, MPFR_RNDN, k); if (i != j) mpfr_neg (x, x, MPFR_RNDN); if (! mpfr_equal_p (z, x) || mpfr_nanflag_p ()) { printf ("Error in mpfr_copysign (%c1250, %cNaN)/n", i ? '-' : '+', j ? '-' : '+'); exit (1); } mpfr_set_si (x, i ? -1250 : 1250, MPFR_RNDN); mpfr_set_si (y, j ? -1717 : 1717, MPFR_RNDN); copysign_variant (z, x, y, MPFR_RNDN, k); if (i != j) mpfr_neg (x, x, MPFR_RNDN); if (! mpfr_equal_p (z, x) || mpfr_nanflag_p ()) { printf ("Error in mpfr_copysign (%c1250, %c1717)/n", i ? '-' : '+', j ? '-' : '+'); exit (1); } } mpfr_clear (x); mpfr_clear (y); mpfr_clear (z); tests_end_mpfr (); return 0;}
开发者ID:axDev-toolchain,项目名称:mpfr,代码行数:61,
示例22: mainintmain (int argc, char *argv[]){ mpfr_t x, y, z, s; tests_start_mpfr (); mpfr_init (x); mpfr_init (s); mpfr_init (y); mpfr_init (z); /* check special cases */ mpfr_set_prec (x, 2); mpfr_set_prec (y, 2); mpfr_set_prec (z, 2); mpfr_set_prec (s, 2); mpfr_set_str (x, "-0.75", 10, GMP_RNDN); mpfr_set_str (y, "0.5", 10, GMP_RNDN); mpfr_set_str (z, "0.375", 10, GMP_RNDN); mpfr_fma (s, x, y, z, GMP_RNDU); /* result is 0 */ if (mpfr_cmp_ui(s, 0)) { printf("Error: -0.75 * 0.5 + 0.375 should be equal to 0 for prec=2/n"); exit(1); } mpfr_set_prec (x, 27); mpfr_set_prec (y, 27); mpfr_set_prec (z, 27); mpfr_set_prec (s, 27); mpfr_set_str_binary (x, "1.11111111111111111111111111e-1"); mpfr_set (y, x, GMP_RNDN); mpfr_set_str_binary (z, "-1.00011110100011001011001001e-1"); if (mpfr_fma (s, x, y, z, GMP_RNDN) >= 0) { printf ("Wrong inexact flag for x=y=1-2^(-27)/n"); exit (1); } mpfr_set_nan (x); mpfr_random (y); mpfr_random (z); mpfr_fma (s, x, y, z, GMP_RNDN); if (!mpfr_nan_p (s)) { printf ("evaluation of function in x=NAN does not return NAN"); exit (1); } mpfr_set_nan (y); mpfr_random (x); mpfr_random (z); mpfr_fma (s, x, y, z, GMP_RNDN); if (!mpfr_nan_p(s)) { printf ("evaluation of function in y=NAN does not return NAN"); exit (1); } mpfr_set_nan (z); mpfr_random (y); mpfr_random (x); mpfr_fma (s, x, y, z, GMP_RNDN); if (!mpfr_nan_p (s)) { printf ("evaluation of function in z=NAN does not return NAN"); exit (1); } mpfr_set_inf (x, 1); mpfr_set_inf (y, 1); mpfr_set_inf (z, 1); mpfr_fma (s, x, y, z, GMP_RNDN); if (!mpfr_inf_p (s) || mpfr_sgn (s) < 0) { printf ("Error for (+inf) * (+inf) + (+inf)/n"); exit (1); } mpfr_set_inf (x, -1); mpfr_set_inf (y, -1); mpfr_set_inf (z, 1); mpfr_fma (s, x, y, z, GMP_RNDN); if (!mpfr_inf_p (s) || mpfr_sgn (s) < 0) { printf ("Error for (-inf) * (-inf) + (+inf)/n"); exit (1); } mpfr_set_inf (x, 1); mpfr_set_inf (y, -1); mpfr_set_inf (z, -1); mpfr_fma (s, x, y, z, GMP_RNDN); if (!mpfr_inf_p (s) || mpfr_sgn (s) > 0) { printf ("Error for (+inf) * (-inf) + (-inf)/n"); exit (1); }//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,
示例23: mainintmain (int argc, char *argv[]){#if MPFR_VERSION >= MPFR_VERSION_NUM(2,3,0) unsigned int prec, yprec; int rnd; mpfr_t x, y, z, t; int inexact; unsigned long n; tests_start_mpfr (); mpfr_init (x); mpfr_init (y); mpfr_init (z); mpfr_init (t); if (argc >= 3) /* tzeta_ui n prec [rnd] */ { mpfr_set_prec (x, atoi (argv[2])); mpfr_zeta_ui (x, atoi (argv[1]), argc > 3 ? (mp_rnd_t) atoi (argv[3]) : GMP_RNDN); mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); printf ("/n"); goto clear_and_exit; } mpfr_set_prec (x, 33); mpfr_set_prec (y, 33); mpfr_zeta_ui (x, 3, GMP_RNDZ); mpfr_set_str_binary (y, "0.100110011101110100000000001001111E1"); if (mpfr_cmp (x, y)) { printf ("Error for zeta(3), prec=33, GMP_RNDZ/n"); printf ("expected "); mpfr_dump (y); printf ("got "); mpfr_dump (x); exit (1); } for (prec = MPFR_PREC_MIN; prec <= 100; prec++) { mpfr_set_prec (x, prec); mpfr_set_prec (z, prec); mpfr_set_prec (t, prec); yprec = prec + 10; mpfr_set_prec (y, yprec); for (n = 0; n < 50; n++) for (rnd = 0; rnd < GMP_RND_MAX; rnd++) { inexact = mpfr_zeta_ui (y, n, GMP_RNDN); if (mpfr_can_round (y, yprec, GMP_RNDN, GMP_RNDZ, prec + (rnd == GMP_RNDN))) { mpfr_set (t, y, (mp_rnd_t) rnd); inexact = mpfr_zeta_ui (z, n, (mp_rnd_t) rnd); if (mpfr_cmp (t, z)) { printf ("results differ for n=%lu", n); printf (" prec=%u rnd_mode=%s/n", prec, mpfr_print_rnd_mode ((mp_rnd_t) rnd)); printf (" got "); mpfr_dump (z); printf (" expected "); mpfr_dump (t); printf (" approx "); mpfr_dump (y); exit (1); } } } } clear_and_exit: mpfr_clear (x); mpfr_clear (y); mpfr_clear (z); mpfr_clear (t); tests_end_mpfr ();#endif return 0;}
开发者ID:Scorpiion,项目名称:Renux_cross_gcc,代码行数:83,
示例24: mainintmain (int argc, char *argv[]){ mpfr_t x, y, r; long q[1]; if (argc == 3) /* usage: tremquo x y (rnd=MPFR_RNDN implicit) */ { mpfr_init2 (x, GMP_NUMB_BITS); mpfr_init2 (y, GMP_NUMB_BITS); mpfr_init2 (r, GMP_NUMB_BITS); mpfr_set_str (x, argv[1], 10, MPFR_RNDN); mpfr_set_str (y, argv[2], 10, MPFR_RNDN); mpfr_remquo (r, q, x, y, MPFR_RNDN); printf ("r="); mpfr_out_str (stdout, 10, 0, r, MPFR_RNDN); printf (" q=%ld/n", q[0]); mpfr_clear (x); mpfr_clear (y); mpfr_clear (r); return 0; } tests_start_mpfr (); bug20090227 (); mpfr_init (x); mpfr_init (y); mpfr_init (r); /* special values */ mpfr_set_nan (x); mpfr_set_ui (y, 1, MPFR_RNDN); mpfr_remquo (r, q, x, y, MPFR_RNDN); MPFR_ASSERTN(mpfr_nan_p (r)); mpfr_set_ui (x, 1, MPFR_RNDN); mpfr_set_nan (y); mpfr_remquo (r, q, x, y, MPFR_RNDN); MPFR_ASSERTN(mpfr_nan_p (r)); mpfr_set_inf (x, 1); /* +Inf */ mpfr_set_ui (y, 1, MPFR_RNDN); mpfr_remquo (r, q, x, y, MPFR_RNDN); MPFR_ASSERTN (mpfr_nan_p (r)); mpfr_set_inf (x, 1); /* +Inf */ mpfr_set_ui (y, 0, MPFR_RNDN); mpfr_remquo (r, q, x, y, MPFR_RNDN); MPFR_ASSERTN (mpfr_nan_p (r)); mpfr_set_inf (x, 1); /* +Inf */ mpfr_set_inf (y, 1); mpfr_remquo (r, q, x, y, MPFR_RNDN); MPFR_ASSERTN (mpfr_nan_p (r)); mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_set_inf (y, 1); mpfr_remquo (r, q, x, y, MPFR_RNDN); MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_POS (r)); MPFR_ASSERTN (q[0] == (long) 0); mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_neg (x, x, MPFR_RNDN); /* -0 */ mpfr_set_inf (y, 1); mpfr_remquo (r, q, x, y, MPFR_RNDN); MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_NEG (r)); MPFR_ASSERTN (q[0] == (long) 0); mpfr_set_ui (x, 17, MPFR_RNDN); mpfr_set_inf (y, 1); mpfr_remquo (r, q, x, y, MPFR_RNDN); MPFR_ASSERTN (mpfr_cmp (r, x) == 0); MPFR_ASSERTN (q[0] == (long) 0); mpfr_set_ui (x, 17, MPFR_RNDN); mpfr_set_ui (y, 0, MPFR_RNDN); mpfr_remquo (r, q, x, y, MPFR_RNDN); MPFR_ASSERTN (mpfr_nan_p (r)); mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_set_ui (y, 17, MPFR_RNDN); mpfr_remquo (r, q, x, y, MPFR_RNDN); MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_POS (r)); MPFR_ASSERTN (q[0] == (long) 0); mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_neg (x, x, MPFR_RNDN); mpfr_set_ui (y, 17, MPFR_RNDN); mpfr_remquo (r, q, x, y, MPFR_RNDN); MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_NEG (r)); MPFR_ASSERTN (q[0] == (long) 0); mpfr_set_prec (x, 53); mpfr_set_prec (y, 53); /* check four possible sign combinations */ mpfr_set_ui (x, 42, MPFR_RNDN); mpfr_set_ui (y, 17, MPFR_RNDN);//.........这里部分代码省略.........
开发者ID:119,项目名称:aircam-openwrt,代码行数:101,
示例25: mainintmain (void){ mpfr_t x; mpfr_exp_t emax; tests_start_mpfr (); mpfr_init (x); mpfr_set_nan (x); mpfr_prec_round (x, 2, MPFR_RNDN); MPFR_ASSERTN(mpfr_nan_p (x)); mpfr_set_inf (x, 1); mpfr_prec_round (x, 2, MPFR_RNDN); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0); mpfr_set_inf (x, -1); mpfr_prec_round (x, 2, MPFR_RNDN); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) < 0); mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_prec_round (x, 2, MPFR_RNDN); MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_POS(x)); mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_neg (x, x, MPFR_RNDN); mpfr_prec_round (x, 2, MPFR_RNDN); MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_NEG(x)); emax = mpfr_get_emax (); set_emax (0); mpfr_set_prec (x, 3); mpfr_set_str_binary (x, "0.111"); mpfr_prec_round (x, 2, MPFR_RNDN); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0); set_emax (emax); mpfr_set_prec (x, mp_bits_per_limb + 2); mpfr_set_ui (x, 1, MPFR_RNDN); mpfr_nextbelow (x); mpfr_prec_round (x, mp_bits_per_limb + 1, MPFR_RNDN); MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0); mpfr_set_prec (x, 3); mpfr_set_ui (x, 5, MPFR_RNDN); mpfr_prec_round (x, 2, MPFR_RNDN); if (mpfr_cmp_ui(x, 4)) { printf ("Error in tround: got "); mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN); printf (" instead of 4/n"); exit (1); } /* check case when reallocation is needed */ mpfr_set_prec (x, 3); mpfr_set_ui (x, 5, MPFR_RNDN); /* exact */ mpfr_prec_round (x, mp_bits_per_limb + 1, MPFR_RNDN); if (mpfr_cmp_ui(x, 5)) { printf ("Error in tround: got "); mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN); printf (" instead of 5/n"); exit (1); } mpfr_clear(x); mpfr_init2 (x, 3); mpfr_set_si (x, -5, MPFR_RNDN); /* exact */ mpfr_prec_round (x, mp_bits_per_limb + 1, MPFR_RNDN); if (mpfr_cmp_si(x, -5)) { printf ("Error in tround: got "); mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN); printf (" instead of -5/n"); exit (1); } /* check case when new precision needs less limbs */ mpfr_set_prec (x, mp_bits_per_limb + 1); mpfr_set_ui (x, 5, MPFR_RNDN); /* exact */ mpfr_prec_round (x, 3, MPFR_RNDN); /* exact */ if (mpfr_cmp_ui(x, 5)) { printf ("Error in tround: got "); mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN); printf (" instead of 5/n"); exit (1); } mpfr_clear(x); tests_end_mpfr (); return 0;}
开发者ID:BreakawayConsulting,项目名称:mpfr,代码行数:97,
示例26: mainintmain (void){ mpfr_t x, y; float f, g, infp; int i; infp = (float) DBL_POS_INF; if (infp * 0.5 != infp) { fprintf (stderr, "Error, FLT_MAX + FLT_MAX does not yield INFP/n"); fprintf (stderr, "(this is probably a compiler bug, please report)/n"); exit (1); } tests_start_mpfr (); mpfr_init2 (x, 24); mpfr_init2 (y, 24);#if !defined(MPFR_ERRDIVZERO) mpfr_set_nan (x); f = mpfr_get_flt (x, MPFR_RNDN); if (f == f) { printf ("Error for mpfr_get_flt(NaN)/n"); exit (1); } mpfr_set_flt (x, f, MPFR_RNDN); if (mpfr_nan_p (x) == 0) { printf ("Error for mpfr_set_flt(NaN)/n"); exit (1); } mpfr_set_inf (x, 1); f = mpfr_get_flt (x, MPFR_RNDN); mpfr_set_flt (x, f, MPFR_RNDN); if (mpfr_inf_p (x) == 0 || mpfr_sgn (x) < 0) { printf ("Error for mpfr_set_flt(mpfr_get_flt(+Inf)):/n"); printf ("f=%f, expected -Inf/n", f); printf ("got "); mpfr_dump (x); exit (1); } mpfr_set_inf (x, -1); f = mpfr_get_flt (x, MPFR_RNDN); mpfr_set_flt (x, f, MPFR_RNDN); if (mpfr_inf_p (x) == 0 || mpfr_sgn (x) > 0) { printf ("Error for mpfr_set_flt(mpfr_get_flt(-Inf)):/n"); printf ("f=%f, expected -Inf/n", f); printf ("got "); mpfr_dump (x); exit (1); }#endif mpfr_set_ui (x, 0, MPFR_RNDN); f = mpfr_get_flt (x, MPFR_RNDN); mpfr_set_flt (x, f, MPFR_RNDN); if (mpfr_zero_p (x) == 0 || MPFR_SIGN (x) < 0) { printf ("Error for mpfr_set_flt(mpfr_get_flt(+0))/n"); exit (1); }#ifdef HAVE_SIGNEDZ mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_neg (x, x, MPFR_RNDN); f = mpfr_get_flt (x, MPFR_RNDN); mpfr_set_flt (x, f, MPFR_RNDN); if (mpfr_zero_p (x) == 0 || MPFR_SIGN (x) > 0) { printf ("Error for mpfr_set_flt(mpfr_get_flt(-0))/n"); exit (1); }#endif /* HAVE_SIGNEDZ */ mpfr_set_ui (x, 17, MPFR_RNDN); f = mpfr_get_flt (x, MPFR_RNDN); mpfr_set_flt (x, f, MPFR_RNDN); if (mpfr_cmp_ui (x, 17) != 0) { printf ("Error for mpfr_set_flt(mpfr_get_flt(17))/n"); printf ("expected 17/n"); printf ("got "); mpfr_dump (x); exit (1); } mpfr_set_si (x, -42, MPFR_RNDN); f = mpfr_get_flt (x, MPFR_RNDN); mpfr_set_flt (x, f, MPFR_RNDN); if (mpfr_cmp_si (x, -42) != 0) { printf ("Error for mpfr_set_flt(mpfr_get_flt(-42))/n"); printf ("expected -42/n"); printf ("got "); mpfr_dump (x);//.........这里部分代码省略.........
开发者ID:epowers,项目名称:mpfr,代码行数:101,
示例27: mainintmain (int argc, char *argv[]){ mpfr_t x, y; unsigned long k, bd, nc, i; char *str, *str2; mp_exp_t e; int base, logbase, prec, baseprec, ret; tests_start_mpfr (); if (argc >= 2) /* tset_str <string> [<prec>] [<base>] */ { prec = (argc >= 3) ? atoi (argv[2]) : 53; base = (argc >= 4) ? atoi (argv[3]) : 2; mpfr_init2 (x, prec); mpfr_set_str (x, argv[1], base, GMP_RNDN); mpfr_out_str (stdout, 10, 0, x, GMP_RNDN); puts (""); mpfr_clear (x); return 0; } mpfr_init2 (x, 2); nc = (argc > 1) ? atoi(argv[1]) : 53; if (nc < 100) nc = 100; bd = randlimb () & 8; str2 = str = (char*) (*__gmp_allocate_func) (nc * sizeof(char)); if (bd) { for(k = 1; k <= bd; k++) *(str2++) = (randlimb () & 1) + '0'; } else *(str2++) = '0'; *(str2++) = '.'; for (k = 1; k < nc - 17 - bd; k++) *(str2++) = '0' + (char) (randlimb () & 1); *(str2++) = 'e'; sprintf (str2, "%d", (int) (randlimb () & INT_MAX) + INT_MIN/2); mpfr_set_prec (x, nc + 10); mpfr_set_str_binary (x, str); mpfr_set_prec (x, 54); mpfr_set_str_binary (x, "0.100100100110110101001010010101111000001011100100101010E-529"); mpfr_init2 (y, 54); mpfr_set_str (y, "[email C++ testutil_check函数代码示例 C++ tests_quiet函数代码示例
|