1/* Test file for mpfr_fms. 2 3Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 4Contributed by the Arenaire and Cacao projects, INRIA. 5 6This file is part of the GNU MPFR Library. 7 8The GNU MPFR Library is free software; you can redistribute it and/or modify 9it under the terms of the GNU Lesser General Public License as published by 10the Free Software Foundation; either version 3 of the License, or (at your 11option) any later version. 12 13The GNU MPFR Library is distributed in the hope that it will be useful, but 14WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16License for more details. 17 18You should have received a copy of the GNU Lesser General Public License 19along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see 20http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 2151 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ 22 23#include <stdio.h> 24#include <stdlib.h> 25 26#include "mpfr-test.h" 27 28/* When a * b is exact, the FMS is equivalent to the separate operations. */ 29static void 30test_exact (void) 31{ 32 char *val[] = 33 { "@NaN@", "-@Inf@", "-2", "-1", "-0", "0", "1", "2", "@Inf@" }; 34 int sv = sizeof (val) / sizeof (*val); 35 int i, j, k; 36 int rnd; 37 mpfr_t a, b, c, r1, r2; 38 39 mpfr_inits2 (8, a, b, c, r1, r2, (mpfr_ptr) 0); 40 41 for (i = 0; i < sv; i++) 42 for (j = 0; j < sv; j++) 43 for (k = 0; k < sv; k++) 44 RND_LOOP (rnd) 45 { 46 if (mpfr_set_str (a, val[i], 10, MPFR_RNDN) || 47 mpfr_set_str (b, val[j], 10, MPFR_RNDN) || 48 mpfr_set_str (c, val[k], 10, MPFR_RNDN) || 49 mpfr_mul (r1, a, b, (mpfr_rnd_t) rnd) || 50 mpfr_sub (r1, r1, c, (mpfr_rnd_t) rnd)) 51 { 52 printf ("test_exact internal error for (%d,%d,%d,%d)\n", 53 i, j, k, rnd); 54 exit (1); 55 } 56 if (mpfr_fms (r2, a, b, c, (mpfr_rnd_t) rnd)) 57 { 58 printf ("test_exact(%d,%d,%d,%d): mpfr_fms should be exact\n", 59 i, j, k, rnd); 60 exit (1); 61 } 62 if (MPFR_IS_NAN (r1)) 63 { 64 if (MPFR_IS_NAN (r2)) 65 continue; 66 printf ("test_exact(%d,%d,%d,%d): mpfr_fms should be NaN\n", 67 i, j, k, rnd); 68 exit (1); 69 } 70 if (mpfr_cmp (r1, r2) || MPFR_SIGN (r1) != MPFR_SIGN (r2)) 71 { 72 printf ("test_exact(%d,%d,%d,%d):\nexpected ", i, j, k, rnd); 73 mpfr_out_str (stdout, 10, 0, r1, MPFR_RNDN); 74 printf ("\n got "); 75 mpfr_out_str (stdout, 10, 0, r2, MPFR_RNDN); 76 printf ("\n"); 77 exit (1); 78 } 79 } 80 81 mpfr_clears (a, b, c, r1, r2, (mpfr_ptr) 0); 82} 83 84static void 85test_overflow1 (void) 86{ 87 mpfr_t x, y, z, r; 88 int inex; 89 90 mpfr_inits2 (8, x, y, z, r, (mpfr_ptr) 0); 91 MPFR_SET_POS (x); 92 mpfr_setmax (x, mpfr_get_emax ()); /* x = 2^emax - ulp */ 93 mpfr_set_ui (y, 2, MPFR_RNDN); /* y = 2 */ 94 mpfr_set (z, x, MPFR_RNDN); /* z = x = 2^emax - ulp */ 95 mpfr_clear_flags (); 96 /* The intermediate multiplication x * y overflows, but x * y - z = x 97 is representable. */ 98 inex = mpfr_fms (r, x, y, z, MPFR_RNDN); 99 if (inex || ! mpfr_equal_p (r, x)) 100 { 101 printf ("Error in test_overflow1\nexpected "); 102 mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN); 103 printf (" with inex = 0\n got "); 104 mpfr_out_str (stdout, 2, 0, r, MPFR_RNDN); 105 printf (" with inex = %d\n", inex); 106 exit (1); 107 } 108 if (mpfr_overflow_p ()) 109 { 110 printf ("Error in test_overflow1: overflow flag set\n"); 111 exit (1); 112 } 113 mpfr_clears (x, y, z, r, (mpfr_ptr) 0); 114} 115 116static void 117test_overflow2 (void) 118{ 119 mpfr_t x, y, z, r; 120 int i, inex, rnd, err = 0; 121 122 mpfr_inits2 (8, x, y, z, r, (mpfr_ptr) 0); 123 124 MPFR_SET_POS (x); 125 mpfr_setmin (x, mpfr_get_emax ()); /* x = 0.1@emax */ 126 mpfr_set_si (y, -2, MPFR_RNDN); /* y = -2 */ 127 /* The intermediate multiplication x * y will overflow. */ 128 129 for (i = -9; i <= 9; i++) 130 RND_LOOP (rnd) 131 { 132 int inf, overflow; 133 134 inf = rnd == MPFR_RNDN || rnd == MPFR_RNDD || rnd == MPFR_RNDA; 135 overflow = inf || i <= 0; 136 137 inex = mpfr_set_si_2exp (z, -i, mpfr_get_emin (), MPFR_RNDN); 138 MPFR_ASSERTN (inex == 0); 139 140 mpfr_clear_flags (); 141 /* One has: x * y = -1@emax exactly (but not representable). */ 142 inex = mpfr_fms (r, x, y, z, (mpfr_rnd_t) rnd); 143 if (overflow ^ (mpfr_overflow_p () != 0)) 144 { 145 printf ("Error in test_overflow2 (i = %d, %s): wrong overflow" 146 " flag (should be %d)\n", i, 147 mpfr_print_rnd_mode ((mpfr_rnd_t) rnd), overflow); 148 err = 1; 149 } 150 if (mpfr_nanflag_p ()) 151 { 152 printf ("Error in test_overflow2 (i = %d, %s): NaN flag should" 153 " not be set\n", i, mpfr_print_rnd_mode ((mpfr_rnd_t) rnd)); 154 err = 1; 155 } 156 if (mpfr_nan_p (r)) 157 { 158 printf ("Error in test_overflow2 (i = %d, %s): got NaN\n", 159 i, mpfr_print_rnd_mode ((mpfr_rnd_t) rnd)); 160 err = 1; 161 } 162 else if (MPFR_SIGN (r) >= 0) 163 { 164 printf ("Error in test_overflow2 (i = %d, %s): wrong sign " 165 "(+ instead of -)\n", i, 166 mpfr_print_rnd_mode ((mpfr_rnd_t) rnd)); 167 err = 1; 168 } 169 else if (inf && ! mpfr_inf_p (r)) 170 { 171 printf ("Error in test_overflow2 (i = %d, %s): expected -Inf," 172 " got\n", i, mpfr_print_rnd_mode ((mpfr_rnd_t) rnd)); 173 mpfr_dump (r); 174 err = 1; 175 } 176 else if (!inf && (mpfr_inf_p (r) || 177 (mpfr_nextbelow (r), ! mpfr_inf_p (r)))) 178 { 179 printf ("Error in test_overflow2 (i = %d, %s): expected -MAX," 180 " got\n", i, mpfr_print_rnd_mode ((mpfr_rnd_t) rnd)); 181 mpfr_dump (r); 182 err = 1; 183 } 184 if (inf ? inex >= 0 : inex <= 0) 185 { 186 printf ("Error in test_overflow2 (i = %d, %s): wrong inexact" 187 " flag (got %d)\n", i, 188 mpfr_print_rnd_mode ((mpfr_rnd_t) rnd), inex); 189 err = 1; 190 } 191 192 } 193 194 if (err) 195 exit (1); 196 mpfr_clears (x, y, z, r, (mpfr_ptr) 0); 197} 198 199static void 200test_underflow1 (void) 201{ 202 mpfr_t x, y, z, r; 203 int inex, signy, signz, rnd, err = 0; 204 205 mpfr_inits2 (8, x, y, z, r, (mpfr_ptr) 0); 206 207 MPFR_SET_POS (x); 208 mpfr_setmin (x, mpfr_get_emin ()); /* x = 0.1@emin */ 209 210 for (signy = -1; signy <= 1; signy += 2) 211 { 212 mpfr_set_si_2exp (y, signy, -1, MPFR_RNDN); /* |y| = 1/2 */ 213 for (signz = -3; signz <= 3; signz += 2) 214 { 215 RND_LOOP (rnd) 216 { 217 mpfr_set_si (z, signz, MPFR_RNDN); 218 if (ABS (signz) != 1) 219 mpfr_setmax (z, mpfr_get_emax ()); 220 /* |z| = 1 or 2^emax - ulp */ 221 mpfr_clear_flags (); 222 inex = mpfr_fms (r, x, y, z, (mpfr_rnd_t) rnd); 223#define ERRTU1 "Error in test_underflow1 (signy = %d, signz = %d, %s)\n " 224 if (mpfr_nanflag_p ()) 225 { 226 printf (ERRTU1 "NaN flag is set\n", signy, signz, 227 mpfr_print_rnd_mode ((mpfr_rnd_t) rnd)); 228 err = 1; 229 } 230 mpfr_neg (z, z, MPFR_RNDN); 231 if (signy < 0 && MPFR_IS_LIKE_RNDD(rnd, -signz)) 232 mpfr_nextbelow (z); 233 if (signy > 0 && MPFR_IS_LIKE_RNDU(rnd, -signz)) 234 mpfr_nextabove (z); 235 if ((mpfr_overflow_p () != 0) ^ (mpfr_inf_p (z) != 0)) 236 { 237 printf (ERRTU1 "wrong overflow flag\n", signy, signz, 238 mpfr_print_rnd_mode ((mpfr_rnd_t) rnd)); 239 err = 1; 240 } 241 if (mpfr_underflow_p ()) 242 { 243 printf (ERRTU1 "underflow flag is set\n", signy, signz, 244 mpfr_print_rnd_mode ((mpfr_rnd_t) rnd)); 245 err = 1; 246 } 247 if (! mpfr_equal_p (r, z)) 248 { 249 printf (ERRTU1 "got ", signy, signz, 250 mpfr_print_rnd_mode ((mpfr_rnd_t) rnd)); 251 mpfr_print_binary (r); 252 printf (" instead of "); 253 mpfr_print_binary (z); 254 printf ("\n"); 255 err = 1; 256 } 257 if (inex >= 0 && (rnd == MPFR_RNDD || 258 (rnd == MPFR_RNDZ && signz < 0) || 259 (rnd == MPFR_RNDN && signy > 0))) 260 { 261 printf (ERRTU1 "ternary value = %d instead of < 0\n", 262 signy, signz, mpfr_print_rnd_mode ((mpfr_rnd_t) rnd), 263 inex); 264 err = 1; 265 } 266 if (inex <= 0 && (rnd == MPFR_RNDU || 267 (rnd == MPFR_RNDZ && signz > 0) || 268 (rnd == MPFR_RNDN && signy < 0))) 269 { 270 printf (ERRTU1 "ternary value = %d instead of > 0\n", 271 signy, signz, mpfr_print_rnd_mode ((mpfr_rnd_t) rnd), 272 inex); 273 err = 1; 274 } 275 } 276 } 277 } 278 279 if (err) 280 exit (1); 281 mpfr_clears (x, y, z, r, (mpfr_ptr) 0); 282} 283 284static void 285test_underflow2 (void) 286{ 287 mpfr_t x, y, z, r; 288 int b, i, inex, same, err = 0; 289 290 mpfr_inits2 (32, x, y, z, r, (mpfr_ptr) 0); 291 292 mpfr_set_si_2exp (z, -1, mpfr_get_emin (), MPFR_RNDN); /* z = -2^emin */ 293 mpfr_set_si_2exp (x, 1, mpfr_get_emin (), MPFR_RNDN); /* x = 2^emin */ 294 295 for (b = 0; b <= 1; b++) 296 { 297 for (i = 15; i <= 17; i++) 298 { 299 mpfr_set_si_2exp (y, i, -4 - MPFR_PREC (z), MPFR_RNDN); 300 /* z = -1.000...00b 301 * xy = 01111 302 * or 10000 303 * or 10001 304 */ 305 mpfr_clear_flags (); 306 inex = mpfr_fms (r, x, y, z, MPFR_RNDN); 307#define ERRTU2 "Error in test_underflow2 (b = %d, i = %d)\n " 308 if (__gmpfr_flags != MPFR_FLAGS_INEXACT) 309 { 310 printf (ERRTU2 "flags = %u instead of %u\n", b, i, 311 __gmpfr_flags, (unsigned int) MPFR_FLAGS_INEXACT); 312 err = 1; 313 } 314 same = i == 15 || (i == 16 && b == 0); 315 if (same ? (inex >= 0) : (inex <= 0)) 316 { 317 printf (ERRTU2 "incorrect ternary value (%d instead of %c 0)\n", 318 b, i, inex, same ? '<' : '>'); 319 err = 1; 320 } 321 mpfr_neg (y, z, MPFR_RNDN); 322 if (!same) 323 mpfr_nextabove (y); 324 if (! mpfr_equal_p (r, y)) 325 { 326 printf (ERRTU2 "expected ", b, i); 327 mpfr_dump (y); 328 printf (" got "); 329 mpfr_dump (r); 330 err = 1; 331 } 332 } 333 mpfr_nextbelow (z); 334 } 335 336 if (err) 337 exit (1); 338 mpfr_clears (x, y, z, r, (mpfr_ptr) 0); 339} 340 341int 342main (int argc, char *argv[]) 343{ 344 mpfr_t x, y, z, s; 345 MPFR_SAVE_EXPO_DECL (expo); 346 347 tests_start_mpfr (); 348 349 mpfr_init (x); 350 mpfr_init (s); 351 mpfr_init (y); 352 mpfr_init (z); 353 354 /* check special cases */ 355 mpfr_set_prec (x, 2); 356 mpfr_set_prec (y, 2); 357 mpfr_set_prec (z, 2); 358 mpfr_set_prec (s, 2); 359 mpfr_set_str (x, "-0.75", 10, MPFR_RNDN); 360 mpfr_set_str (y, "0.5", 10, MPFR_RNDN); 361 mpfr_set_str (z, "-0.375", 10, MPFR_RNDN); 362 mpfr_fms (s, x, y, z, MPFR_RNDU); /* result is 0 */ 363 if (mpfr_cmp_ui(s, 0)) 364 { 365 printf("Error: -0.75 * 0.5 - -0.375 should be equal to 0 for prec=2\n"); 366 exit(1); 367 } 368 369 mpfr_set_prec (x, 27); 370 mpfr_set_prec (y, 27); 371 mpfr_set_prec (z, 27); 372 mpfr_set_prec (s, 27); 373 mpfr_set_str_binary (x, "1.11111111111111111111111111e-1"); 374 mpfr_set (y, x, MPFR_RNDN); 375 mpfr_set_str_binary (z, "1.00011110100011001011001001e-1"); 376 if (mpfr_fms (s, x, y, z, MPFR_RNDN) >= 0) 377 { 378 printf ("Wrong inexact flag for x=y=1-2^(-27)\n"); 379 exit (1); 380 } 381 382 mpfr_set_nan (x); 383 mpfr_urandomb (y, RANDS); 384 mpfr_urandomb (z, RANDS); 385 mpfr_fms (s, x, y, z, MPFR_RNDN); 386 if (!mpfr_nan_p (s)) 387 { 388 printf ("evaluation of function in x=NAN does not return NAN"); 389 exit (1); 390 } 391 392 mpfr_set_nan (y); 393 mpfr_urandomb (x, RANDS); 394 mpfr_urandomb (z, RANDS); 395 mpfr_fms (s, x, y, z, MPFR_RNDN); 396 if (!mpfr_nan_p(s)) 397 { 398 printf ("evaluation of function in y=NAN does not return NAN"); 399 exit (1); 400 } 401 402 mpfr_set_nan (z); 403 mpfr_urandomb (y, RANDS); 404 mpfr_urandomb (x, RANDS); 405 mpfr_fms (s, x, y, z, MPFR_RNDN); 406 if (!mpfr_nan_p (s)) 407 { 408 printf ("evaluation of function in z=NAN does not return NAN"); 409 exit (1); 410 } 411 412 mpfr_set_inf (x, 1); 413 mpfr_set_inf (y, 1); 414 mpfr_set_inf (z, -1); 415 mpfr_fms (s, x, y, z, MPFR_RNDN); 416 if (!mpfr_inf_p (s) || mpfr_sgn (s) < 0) 417 { 418 printf ("Error for (+inf) * (+inf) - (-inf)\n"); 419 exit (1); 420 } 421 422 mpfr_set_inf (x, -1); 423 mpfr_set_inf (y, -1); 424 mpfr_set_inf (z, -1); 425 mpfr_fms (s, x, y, z, MPFR_RNDN); 426 if (!mpfr_inf_p (s) || mpfr_sgn (s) < 0) 427 { 428 printf ("Error for (-inf) * (-inf) - (-inf)\n"); 429 exit (1); 430 } 431 432 mpfr_set_inf (x, 1); 433 mpfr_set_inf (y, -1); 434 mpfr_set_inf (z, 1); 435 mpfr_fms (s, x, y, z, MPFR_RNDN); 436 if (!mpfr_inf_p (s) || mpfr_sgn (s) > 0) 437 { 438 printf ("Error for (+inf) * (-inf) - (+inf)\n"); 439 exit (1); 440 } 441 442 mpfr_set_inf (x, -1); 443 mpfr_set_inf (y, 1); 444 mpfr_set_inf (z, 1); 445 mpfr_fms (s, x, y, z, MPFR_RNDN); 446 if (!mpfr_inf_p (s) || mpfr_sgn (s) > 0) 447 { 448 printf ("Error for (-inf) * (+inf) - (+inf)\n"); 449 exit (1); 450 } 451 452 mpfr_set_inf (x, 1); 453 mpfr_set_ui (y, 0, MPFR_RNDN); 454 mpfr_urandomb (z, RANDS); 455 mpfr_fms (s, x, y, z, MPFR_RNDN); 456 if (!mpfr_nan_p (s)) 457 { 458 printf ("evaluation of function in x=INF y=0 does not return NAN"); 459 exit (1); 460 } 461 462 mpfr_set_inf (y, 1); 463 mpfr_set_ui (x, 0, MPFR_RNDN); 464 mpfr_urandomb (z, RANDS); 465 mpfr_fms (s, x, y, z, MPFR_RNDN); 466 if (!mpfr_nan_p (s)) 467 { 468 printf ("evaluation of function in x=0 y=INF does not return NAN"); 469 exit (1); 470 } 471 472 mpfr_set_inf (x, 1); 473 mpfr_urandomb (y, RANDS); /* always positive */ 474 mpfr_set_inf (z, 1); 475 mpfr_fms (s, x, y, z, MPFR_RNDN); 476 if (!mpfr_nan_p (s)) 477 { 478 printf ("evaluation of function in x=INF y>0 z=INF does not return NAN"); 479 exit (1); 480 } 481 482 mpfr_set_inf (y, 1); 483 mpfr_urandomb (x, RANDS); 484 mpfr_set_inf (z, 1); 485 mpfr_fms (s, x, y, z, MPFR_RNDN); 486 if (!mpfr_nan_p (s)) 487 { 488 printf ("evaluation of function in x>0 y=INF z=INF does not return NAN"); 489 exit (1); 490 } 491 492 mpfr_set_inf (x, 1); 493 mpfr_urandomb (y, RANDS); 494 mpfr_urandomb (z, RANDS); 495 mpfr_fms (s, x, y, z, MPFR_RNDN); 496 if (!mpfr_inf_p (s) || mpfr_sgn (s) < 0) 497 { 498 printf ("evaluation of function in x=INF does not return INF"); 499 exit (1); 500 } 501 502 mpfr_set_inf (y, 1); 503 mpfr_urandomb (x, RANDS); 504 mpfr_urandomb (z, RANDS); 505 mpfr_fms (s, x, y, z, MPFR_RNDN); 506 if (!mpfr_inf_p (s) || mpfr_sgn (s) < 0) 507 { 508 printf ("evaluation of function in y=INF does not return INF"); 509 exit (1); 510 } 511 512 mpfr_set_inf (z, -1); 513 mpfr_urandomb (x, RANDS); 514 mpfr_urandomb (y, RANDS); 515 mpfr_fms (s, x, y, z, MPFR_RNDN); 516 if (!mpfr_inf_p (s) || mpfr_sgn (s) < 0) 517 { 518 printf ("evaluation of function in z=-INF does not return INF"); 519 exit (1); 520 } 521 522 mpfr_set_ui (x, 0, MPFR_RNDN); 523 mpfr_urandomb (y, RANDS); 524 mpfr_urandomb (z, RANDS); 525 mpfr_fms (s, x, y, z, MPFR_RNDN); 526 mpfr_neg (z, z, MPFR_RNDN); 527 if (mpfr_cmp (s, z)) 528 { 529 printf ("evaluation of function in x=0 does not return -z\n"); 530 exit (1); 531 } 532 533 mpfr_set_ui (y, 0, MPFR_RNDN); 534 mpfr_urandomb (x, RANDS); 535 mpfr_urandomb (z, RANDS); 536 mpfr_fms (s, x, y, z, MPFR_RNDN); 537 mpfr_neg (z, z, MPFR_RNDN); 538 if (mpfr_cmp (s, z)) 539 { 540 printf ("evaluation of function in y=0 does not return -z\n"); 541 exit (1); 542 } 543 544 { 545 mpfr_prec_t prec; 546 mpfr_t t, slong; 547 mpfr_rnd_t rnd; 548 int inexact, compare; 549 unsigned int n; 550 551 mpfr_prec_t p0=2, p1=200; 552 unsigned int N=200; 553 554 mpfr_init (t); 555 mpfr_init (slong); 556 557 /* generic test */ 558 for (prec = p0; prec <= p1; prec++) 559 { 560 mpfr_set_prec (x, prec); 561 mpfr_set_prec (y, prec); 562 mpfr_set_prec (z, prec); 563 mpfr_set_prec (s, prec); 564 mpfr_set_prec (t, prec); 565 566 for (n=0; n<N; n++) 567 { 568 mpfr_urandomb (x, RANDS); 569 mpfr_urandomb (y, RANDS); 570 mpfr_urandomb (z, RANDS); 571 572 if (randlimb () % 2) 573 mpfr_neg (x, x, MPFR_RNDN); 574 if (randlimb () % 2) 575 mpfr_neg (y, y, MPFR_RNDN); 576 if (randlimb () % 2) 577 mpfr_neg (z, z, MPFR_RNDN); 578 579 rnd = RND_RAND (); 580 mpfr_set_prec (slong, 2 * prec); 581 if (mpfr_mul (slong, x, y, rnd)) 582 { 583 printf ("x*y should be exact\n"); 584 exit (1); 585 } 586 compare = mpfr_sub (t, slong, z, rnd); 587 inexact = mpfr_fms (s, x, y, z, rnd); 588 if (mpfr_cmp (s, t)) 589 { 590 printf ("results differ for x="); 591 mpfr_out_str (stdout, 2, prec, x, MPFR_RNDN); 592 printf (" y="); 593 mpfr_out_str (stdout, 2, prec, y, MPFR_RNDN); 594 printf (" z="); 595 mpfr_out_str (stdout, 2, prec, z, MPFR_RNDN); 596 printf (" prec=%u rnd_mode=%s\n", (unsigned int) prec, 597 mpfr_print_rnd_mode (rnd)); 598 printf ("got "); 599 mpfr_out_str (stdout, 2, prec, s, MPFR_RNDN); 600 puts (""); 601 printf ("expected "); 602 mpfr_out_str (stdout, 2, prec, t, MPFR_RNDN); 603 puts (""); 604 printf ("approx "); 605 mpfr_print_binary (slong); 606 puts (""); 607 exit (1); 608 } 609 if (((inexact == 0) && (compare != 0)) || 610 ((inexact < 0) && (compare >= 0)) || 611 ((inexact > 0) && (compare <= 0))) 612 { 613 printf ("Wrong inexact flag for rnd=%s: expected %d, got %d\n", 614 mpfr_print_rnd_mode (rnd), compare, inexact); 615 printf (" x="); mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN); 616 printf (" y="); mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN); 617 printf (" z="); mpfr_out_str (stdout, 2, 0, z, MPFR_RNDN); 618 printf (" s="); mpfr_out_str (stdout, 2, 0, s, MPFR_RNDN); 619 printf ("\n"); 620 exit (1); 621 } 622 } 623 } 624 mpfr_clear (t); 625 mpfr_clear (slong); 626 627 } 628 mpfr_clear (x); 629 mpfr_clear (y); 630 mpfr_clear (z); 631 mpfr_clear (s); 632 633 test_exact (); 634 635 MPFR_SAVE_EXPO_MARK (expo); 636 test_overflow1 (); 637 test_overflow2 (); 638 test_underflow1 (); 639 test_underflow2 (); 640 MPFR_SAVE_EXPO_FREE (expo); 641 642 tests_end_mpfr (); 643 return 0; 644} 645