1 2/* 3=============================================================================== 4 5This C source file is part of TestFloat, Release 2a, a package of programs 6for testing the correctness of floating-point arithmetic complying to the 7IEC/IEEE Standard for Floating-Point. 8 9Written by John R. Hauser. More information is available through the Web 10page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'. 11 12THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 13has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 14TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO 15PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY 16AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. 17 18Derivative works are acceptable, even for commercial purposes, so long as 19(1) they include prominent notice that the work is derivative, and (2) they 20include prominent notice akin to these four paragraphs for those parts of 21this code that are retained. 22 23=============================================================================== 24*/ 25 26#include <stdlib.h> 27#include <stdio.h> 28#include "milieu.h" 29#include "softfloat.h" 30#include "testCases.h" 31#include "writeHex.h" 32#include "testLoops.h" 33 34volatile flag stop = FALSE; 35 36char *trueName, *testName; 37flag forever, errorStop; 38uint32 maxErrorCount = 0; 39flag checkNaNs = FALSE; 40int8 *trueFlagsPtr; 41int8 ( *testFlagsFunctionPtr )( void ); 42char *functionName; 43char *roundingPrecisionName, *roundingModeName, *tininessModeName; 44flag anyErrors = FALSE; 45 46void writeFunctionName( FILE *stream ) 47{ 48 49 fputs( functionName, stream ); 50 if ( roundingModeName ) { 51 if ( roundingPrecisionName ) { 52 fputs( ", precision ", stream ); 53 fputs( roundingPrecisionName, stream ); 54 } 55 fputs( ", rounding ", stream ); 56 fputs( roundingModeName, stream ); 57 if ( tininessModeName ) { 58 fputs( ", tininess ", stream ); 59 fputs( tininessModeName, stream ); 60 fputs( " rounding", stream ); 61 } 62 } 63 64} 65 66void exitWithStatus( void ) 67{ 68 69 exit( anyErrors ? EXIT_FAILURE : EXIT_SUCCESS ); 70 71} 72 73static uint32 tenthousandsCount, errorCount = 0; 74 75static void writeTestsTotal( void ) 76{ 77 78 if ( forever ) { 79 fputs( "Unbounded tests.\n", stderr ); 80 } 81 else { 82 fprintf( stderr, "\r%d tests total.\n", testCases_total ); 83 } 84 85} 86 87static void writeTestsPerformed( int16 count ) 88{ 89 90 if ( tenthousandsCount ) { 91 fprintf( 92 stderr, "\r%d%04d tests performed", tenthousandsCount, count ); 93 } 94 else { 95 fprintf( stderr, "\r%d tests performed", count ); 96 } 97 if ( errorCount ) { 98 fprintf( 99 stderr, 100 "; %d error%s found.\n", 101 errorCount, 102 ( errorCount == 1 ) ? "" : "s" 103 ); 104 } 105 else { 106 fputs( ".\n", stderr ); 107 fputs( "No errors found in ", stdout ); 108 writeFunctionName( stdout ); 109 fputs( ".\n", stdout ); 110 fflush( stdout ); 111 } 112 113} 114 115static void checkEarlyExit( void ) 116{ 117 118 ++tenthousandsCount; 119 if ( stop ) { 120 writeTestsPerformed( 0 ); 121 exitWithStatus(); 122 } 123 fprintf( stderr, "\r%3d0000", tenthousandsCount ); 124 125} 126 127static void writeErrorFound( int16 count ) 128{ 129 130 fputc( '\r', stderr ); 131 if ( errorCount == 1 ) { 132 fputs( "Errors found in ", stdout ); 133 writeFunctionName( stdout ); 134 fputs( ":\n", stdout ); 135 } 136 if ( stop ) { 137 writeTestsPerformed( count ); 138 exitWithStatus(); 139 } 140 anyErrors = TRUE; 141 142} 143 144INLINE void writeInput_a_int32( void ) 145{ 146 147 writeHex_bits32( testCases_a_int32, stdout ); 148 149} 150 151#ifdef BITS64 152 153INLINE void writeInput_a_int64( void ) 154{ 155 156 writeHex_bits64( testCases_a_int64, stdout ); 157 158} 159 160#endif 161 162INLINE void writeInput_a_float32( void ) 163{ 164 165 writeHex_float32( testCases_a_float32, stdout ); 166 167} 168 169static void writeInputs_ab_float32( void ) 170{ 171 172 writeHex_float32( testCases_a_float32, stdout ); 173 fputs( " ", stdout ); 174 writeHex_float32( testCases_b_float32, stdout ); 175 176} 177 178INLINE void writeInput_a_float64( void ) 179{ 180 181 writeHex_float64( testCases_a_float64, stdout ); 182 183} 184 185static void writeInputs_ab_float64( void ) 186{ 187 188 writeHex_float64( testCases_a_float64, stdout ); 189 fputs( " ", stdout ); 190 writeHex_float64( testCases_b_float64, stdout ); 191 192} 193 194#ifdef FLOATX80 195 196INLINE void writeInput_a_floatx80( void ) 197{ 198 199 writeHex_floatx80( testCases_a_floatx80, stdout ); 200 201} 202 203static void writeInputs_ab_floatx80( void ) 204{ 205 206 writeHex_floatx80( testCases_a_floatx80, stdout ); 207 fputs( " ", stdout ); 208 writeHex_floatx80( testCases_b_floatx80, stdout ); 209 210} 211 212#endif 213 214#ifdef FLOAT128 215 216INLINE void writeInput_a_float128( void ) 217{ 218 219 writeHex_float128( testCases_a_float128, stdout ); 220 221} 222 223static void writeInputs_ab_float128( void ) 224{ 225 226 writeHex_float128( testCases_a_float128, stdout ); 227 fputs( " ", stdout ); 228 writeHex_float128( testCases_b_float128, stdout ); 229 230} 231 232#endif 233 234static void 235 writeOutputs_z_flag( 236 flag trueZ, uint8 trueFlags, flag testZ, uint8 testFlags ) 237{ 238 239 fputs( trueName, stdout ); 240 fputs( ": ", stdout ); 241 writeHex_flag( trueZ, stdout ); 242 fputc( ' ', stdout ); 243 writeHex_float_flags( trueFlags, stdout ); 244 fputs( " ", stdout ); 245 fputs( testName, stdout ); 246 fputs( ": ", stdout ); 247 writeHex_flag( testZ, stdout ); 248 fputc( ' ', stdout ); 249 writeHex_float_flags( testFlags, stdout ); 250 fputc( '\n', stdout ); 251 252} 253 254static void 255 writeOutputs_z_int32( 256 int32 trueZ, uint8 trueFlags, int32 testZ, uint8 testFlags ) 257{ 258 259 fputs( trueName, stdout ); 260 fputs( ": ", stdout ); 261 writeHex_bits32( trueZ, stdout ); 262 fputc( ' ', stdout ); 263 writeHex_float_flags( trueFlags, stdout ); 264 fputs( " ", stdout ); 265 fputs( testName, stdout ); 266 fputs( ": ", stdout ); 267 writeHex_bits32( testZ, stdout ); 268 fputc( ' ', stdout ); 269 writeHex_float_flags( testFlags, stdout ); 270 fputc( '\n', stdout ); 271 272} 273 274#ifdef BITS64 275 276static void 277 writeOutputs_z_int64( 278 int64 trueZ, uint8 trueFlags, int64 testZ, uint8 testFlags ) 279{ 280 281 fputs( trueName, stdout ); 282 fputs( ": ", stdout ); 283 writeHex_bits64( trueZ, stdout ); 284 fputc( ' ', stdout ); 285 writeHex_float_flags( trueFlags, stdout ); 286 fputs( " ", stdout ); 287 fputs( testName, stdout ); 288 fputs( ": ", stdout ); 289 writeHex_bits64( testZ, stdout ); 290 fputc( ' ', stdout ); 291 writeHex_float_flags( testFlags, stdout ); 292 fputc( '\n', stdout ); 293 294} 295 296#endif 297 298static void 299 writeOutputs_z_float32( 300 float32 trueZ, uint8 trueFlags, float32 testZ, uint8 testFlags ) 301{ 302 303 fputs( trueName, stdout ); 304 fputs( ": ", stdout ); 305 writeHex_float32( trueZ, stdout ); 306 fputc( ' ', stdout ); 307 writeHex_float_flags( trueFlags, stdout ); 308 fputs( " ", stdout ); 309 fputs( testName, stdout ); 310 fputs( ": ", stdout ); 311 writeHex_float32( testZ, stdout ); 312 fputc( ' ', stdout ); 313 writeHex_float_flags( testFlags, stdout ); 314 fputc( '\n', stdout ); 315 316} 317 318static void 319 writeOutputs_z_float64( 320 float64 trueZ, uint8 trueFlags, float64 testZ, uint8 testFlags ) 321{ 322 323 fputs( trueName, stdout ); 324 fputs( ": ", stdout ); 325 writeHex_float64( trueZ, stdout ); 326 fputc( ' ', stdout ); 327 writeHex_float_flags( trueFlags, stdout ); 328 fputs( " ", stdout ); 329 fputs( testName, stdout ); 330 fputs( ": ", stdout ); 331 writeHex_float64( testZ, stdout ); 332 fputc( ' ', stdout ); 333 writeHex_float_flags( testFlags, stdout ); 334 fputc( '\n', stdout ); 335 336} 337 338#ifdef FLOATX80 339 340static void 341 writeOutputs_z_floatx80( 342 floatx80 trueZ, uint8 trueFlags, floatx80 testZ, uint8 testFlags ) 343{ 344 345 fputs( trueName, stdout ); 346 fputs( ": ", stdout ); 347 writeHex_floatx80( trueZ, stdout ); 348 fputc( ' ', stdout ); 349 writeHex_float_flags( trueFlags, stdout ); 350 fputs( " ", stdout ); 351 fputs( testName, stdout ); 352 fputs( ": ", stdout ); 353 writeHex_floatx80( testZ, stdout ); 354 fputc( ' ', stdout ); 355 writeHex_float_flags( testFlags, stdout ); 356 fputc( '\n', stdout ); 357 358} 359 360#endif 361 362#ifdef FLOAT128 363 364static void 365 writeOutputs_z_float128( 366 float128 trueZ, uint8 trueFlags, float128 testZ, uint8 testFlags ) 367{ 368 369 fputs( trueName, stdout ); 370 fputs( ": ", stdout ); 371 writeHex_float128( trueZ, stdout ); 372 fputc( ' ', stdout ); 373 writeHex_float_flags( trueFlags, stdout ); 374 fputs( "\n\t", stdout ); 375 fputs( testName, stdout ); 376 fputs( ": ", stdout ); 377 writeHex_float128( testZ, stdout ); 378 fputc( ' ', stdout ); 379 writeHex_float_flags( testFlags, stdout ); 380 fputc( '\n', stdout ); 381 382} 383 384#endif 385 386INLINE flag float32_isNaN( float32 a ) 387{ 388 389 return 0x7F800000 < ( a & 0x7FFFFFFF ); 390 391} 392 393#ifdef BITS64 394 395INLINE flag float64_same( float64 a, float64 b ) 396{ 397 398 return a == b; 399 400} 401 402INLINE flag float64_isNaN( float64 a ) 403{ 404 405 return LIT64( 0x7FF0000000000000 ) < ( a & LIT64( 0x7FFFFFFFFFFFFFFF ) ); 406 407} 408 409#else 410 411INLINE flag float64_same( float64 a, float64 b ) 412{ 413 414 return ( a.high == b.high ) && ( a.low == b.low ); 415 416} 417 418INLINE flag float64_isNaN( float64 a ) 419{ 420 bits32 absAHigh; 421 422 absAHigh = a.high & 0x7FFFFFFF; 423 return 424 ( 0x7FF00000 < absAHigh ) || ( ( absAHigh == 0x7FF00000 ) && a.low ); 425 426} 427 428#endif 429 430#ifdef FLOATX80 431 432INLINE flag floatx80_same( floatx80 a, floatx80 b ) 433{ 434 435 return ( a.high == b.high ) && ( a.low == b.low ); 436 437} 438 439INLINE flag floatx80_isNaN( floatx80 a ) 440{ 441 442 return ( ( a.high & 0x7FFF ) == 0x7FFF ) && a.low; 443 444} 445 446#endif 447 448#ifdef FLOAT128 449 450INLINE flag float128_same( float128 a, float128 b ) 451{ 452 453 return ( a.high == b.high ) && ( a.low == b.low ); 454 455} 456 457INLINE flag float128_isNaN( float128 a ) 458{ 459 bits64 absAHigh; 460 461 absAHigh = a.high & LIT64( 0x7FFFFFFFFFFFFFFF ); 462 return 463 ( LIT64( 0x7FFF000000000000 ) < absAHigh ) 464 || ( ( absAHigh == LIT64( 0x7FFF000000000000 ) ) && a.low ); 465 466} 467 468#endif 469 470void 471 test_a_int32_z_float32( 472 float32 trueFunction( int32 ), float32 testFunction( int32 ) ) 473{ 474 int16 count; 475 float32 trueZ, testZ; 476 uint8 trueFlags, testFlags; 477 478 errorCount = 0; 479 tenthousandsCount = 0; 480 count = 10000; 481 testCases_initSequence( testCases_sequence_a_int32 ); 482 writeTestsTotal(); 483 while ( ! testCases_done || forever ) { 484 testCases_next(); 485 *trueFlagsPtr = 0; 486 trueZ = trueFunction( testCases_a_int32 ); 487 trueFlags = *trueFlagsPtr; 488 (void) testFlagsFunctionPtr(); 489 testZ = testFunction( testCases_a_int32 ); 490 testFlags = testFlagsFunctionPtr(); 491 --count; 492 if ( count == 0 ) { 493 checkEarlyExit(); 494 count = 10000; 495 } 496 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 497 if ( ! checkNaNs 498 && float32_isNaN( trueZ ) 499 && float32_isNaN( testZ ) 500 && ! float32_is_signaling_nan( testZ ) 501 && ( trueFlags == testFlags ) 502 ) { 503 /* no problem */ 504 } 505 else { 506 ++errorCount; 507 writeErrorFound( 10000 - count ); 508 writeInput_a_int32(); 509 fputs( " ", stdout ); 510 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags ); 511 fflush( stdout ); 512 if ( errorCount == maxErrorCount ) goto exit; 513 } 514 } 515 } 516 exit: 517 writeTestsPerformed( 10000 - count ); 518 519} 520 521void 522 test_a_int32_z_float64( 523 float64 trueFunction( int32 ), float64 testFunction( int32 ) ) 524{ 525 int16 count; 526 float64 trueZ, testZ; 527 uint8 trueFlags, testFlags; 528 529 errorCount = 0; 530 tenthousandsCount = 0; 531 count = 10000; 532 testCases_initSequence( testCases_sequence_a_int32 ); 533 writeTestsTotal(); 534 while ( ! testCases_done || forever ) { 535 testCases_next(); 536 *trueFlagsPtr = 0; 537 trueZ = trueFunction( testCases_a_int32 ); 538 trueFlags = *trueFlagsPtr; 539 (void) testFlagsFunctionPtr(); 540 testZ = testFunction( testCases_a_int32 ); 541 testFlags = testFlagsFunctionPtr(); 542 --count; 543 if ( count == 0 ) { 544 checkEarlyExit(); 545 count = 10000; 546 } 547 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 548 if ( ! checkNaNs 549 && float64_isNaN( trueZ ) 550 && float64_isNaN( testZ ) 551 && ! float64_is_signaling_nan( testZ ) 552 && ( trueFlags == testFlags ) 553 ) { 554 /* no problem */ 555 } 556 else { 557 ++errorCount; 558 writeErrorFound( 10000 - count ); 559 writeInput_a_int32(); 560 fputs( " ", stdout ); 561 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags ); 562 fflush( stdout ); 563 if ( errorCount == maxErrorCount ) goto exit; 564 } 565 } 566 } 567 exit: 568 writeTestsPerformed( 10000 - count ); 569 570} 571 572#ifdef FLOATX80 573 574void 575 test_a_int32_z_floatx80( 576 floatx80 trueFunction( int32 ), floatx80 testFunction( int32 ) ) 577{ 578 int16 count; 579 floatx80 trueZ, testZ; 580 uint8 trueFlags, testFlags; 581 582 errorCount = 0; 583 tenthousandsCount = 0; 584 count = 10000; 585 testCases_initSequence( testCases_sequence_a_int32 ); 586 writeTestsTotal(); 587 while ( ! testCases_done || forever ) { 588 testCases_next(); 589 *trueFlagsPtr = 0; 590 trueZ = trueFunction( testCases_a_int32 ); 591 trueFlags = *trueFlagsPtr; 592 (void) testFlagsFunctionPtr(); 593 testZ = testFunction( testCases_a_int32 ); 594 testFlags = testFlagsFunctionPtr(); 595 --count; 596 if ( count == 0 ) { 597 checkEarlyExit(); 598 count = 10000; 599 } 600 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 601 if ( ! checkNaNs 602 && floatx80_isNaN( trueZ ) 603 && floatx80_isNaN( testZ ) 604 && ! floatx80_is_signaling_nan( testZ ) 605 && ( trueFlags == testFlags ) 606 ) { 607 /* no problem */ 608 } 609 else { 610 ++errorCount; 611 writeErrorFound( 10000 - count ); 612 writeInput_a_int32(); 613 fputs( " ", stdout ); 614 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags ); 615 fflush( stdout ); 616 if ( errorCount == maxErrorCount ) goto exit; 617 } 618 } 619 } 620 exit: 621 writeTestsPerformed( 10000 - count ); 622 623} 624 625#endif 626 627#ifdef FLOAT128 628 629void 630 test_a_int32_z_float128( 631 float128 trueFunction( int32 ), float128 testFunction( int32 ) ) 632{ 633 int16 count; 634 float128 trueZ, testZ; 635 uint8 trueFlags, testFlags; 636 637 errorCount = 0; 638 tenthousandsCount = 0; 639 count = 10000; 640 testCases_initSequence( testCases_sequence_a_int32 ); 641 writeTestsTotal(); 642 while ( ! testCases_done || forever ) { 643 testCases_next(); 644 *trueFlagsPtr = 0; 645 trueZ = trueFunction( testCases_a_int32 ); 646 trueFlags = *trueFlagsPtr; 647 (void) testFlagsFunctionPtr(); 648 testZ = testFunction( testCases_a_int32 ); 649 testFlags = testFlagsFunctionPtr(); 650 --count; 651 if ( count == 0 ) { 652 checkEarlyExit(); 653 count = 10000; 654 } 655 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 656 if ( ! checkNaNs 657 && float128_isNaN( trueZ ) 658 && float128_isNaN( testZ ) 659 && ! float128_is_signaling_nan( testZ ) 660 && ( trueFlags == testFlags ) 661 ) { 662 /* no problem */ 663 } 664 else { 665 ++errorCount; 666 writeErrorFound( 10000 - count ); 667 writeInput_a_int32(); 668 fputs( "\n\t", stdout ); 669 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags ); 670 fflush( stdout ); 671 if ( errorCount == maxErrorCount ) goto exit; 672 } 673 } 674 } 675 exit: 676 writeTestsPerformed( 10000 - count ); 677 678} 679 680#endif 681 682#ifdef BITS64 683 684void 685 test_a_int64_z_float32( 686 float32 trueFunction( int64 ), float32 testFunction( int64 ) ) 687{ 688 int16 count; 689 float32 trueZ, testZ; 690 uint8 trueFlags, testFlags; 691 692 errorCount = 0; 693 tenthousandsCount = 0; 694 count = 10000; 695 testCases_initSequence( testCases_sequence_a_int64 ); 696 writeTestsTotal(); 697 while ( ! testCases_done || forever ) { 698 testCases_next(); 699 *trueFlagsPtr = 0; 700 trueZ = trueFunction( testCases_a_int64 ); 701 trueFlags = *trueFlagsPtr; 702 (void) testFlagsFunctionPtr(); 703 testZ = testFunction( testCases_a_int64 ); 704 testFlags = testFlagsFunctionPtr(); 705 --count; 706 if ( count == 0 ) { 707 checkEarlyExit(); 708 count = 10000; 709 } 710 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 711 if ( ! checkNaNs 712 && float32_isNaN( trueZ ) 713 && float32_isNaN( testZ ) 714 && ! float32_is_signaling_nan( testZ ) 715 && ( trueFlags == testFlags ) 716 ) { 717 /* no problem */ 718 } 719 else { 720 ++errorCount; 721 writeErrorFound( 10000 - count ); 722 writeInput_a_int64(); 723 fputs( " ", stdout ); 724 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags ); 725 fflush( stdout ); 726 if ( errorCount == maxErrorCount ) goto exit; 727 } 728 } 729 } 730 exit: 731 writeTestsPerformed( 10000 - count ); 732 733} 734 735void 736 test_a_int64_z_float64( 737 float64 trueFunction( int64 ), float64 testFunction( int64 ) ) 738{ 739 int16 count; 740 float64 trueZ, testZ; 741 uint8 trueFlags, testFlags; 742 743 errorCount = 0; 744 tenthousandsCount = 0; 745 count = 10000; 746 testCases_initSequence( testCases_sequence_a_int64 ); 747 writeTestsTotal(); 748 while ( ! testCases_done || forever ) { 749 testCases_next(); 750 *trueFlagsPtr = 0; 751 trueZ = trueFunction( testCases_a_int64 ); 752 trueFlags = *trueFlagsPtr; 753 (void) testFlagsFunctionPtr(); 754 testZ = testFunction( testCases_a_int64 ); 755 testFlags = testFlagsFunctionPtr(); 756 --count; 757 if ( count == 0 ) { 758 checkEarlyExit(); 759 count = 10000; 760 } 761 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 762 if ( ! checkNaNs 763 && float64_isNaN( trueZ ) 764 && float64_isNaN( testZ ) 765 && ! float64_is_signaling_nan( testZ ) 766 && ( trueFlags == testFlags ) 767 ) { 768 /* no problem */ 769 } 770 else { 771 ++errorCount; 772 writeErrorFound( 10000 - count ); 773 writeInput_a_int64(); 774 fputs( " ", stdout ); 775 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags ); 776 fflush( stdout ); 777 if ( errorCount == maxErrorCount ) goto exit; 778 } 779 } 780 } 781 exit: 782 writeTestsPerformed( 10000 - count ); 783 784} 785 786#ifdef FLOATX80 787 788void 789 test_a_int64_z_floatx80( 790 floatx80 trueFunction( int64 ), floatx80 testFunction( int64 ) ) 791{ 792 int16 count; 793 floatx80 trueZ, testZ; 794 uint8 trueFlags, testFlags; 795 796 errorCount = 0; 797 tenthousandsCount = 0; 798 count = 10000; 799 testCases_initSequence( testCases_sequence_a_int64 ); 800 writeTestsTotal(); 801 while ( ! testCases_done || forever ) { 802 testCases_next(); 803 *trueFlagsPtr = 0; 804 trueZ = trueFunction( testCases_a_int64 ); 805 trueFlags = *trueFlagsPtr; 806 (void) testFlagsFunctionPtr(); 807 testZ = testFunction( testCases_a_int64 ); 808 testFlags = testFlagsFunctionPtr(); 809 --count; 810 if ( count == 0 ) { 811 checkEarlyExit(); 812 count = 10000; 813 } 814 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 815 if ( ! checkNaNs 816 && floatx80_isNaN( trueZ ) 817 && floatx80_isNaN( testZ ) 818 && ! floatx80_is_signaling_nan( testZ ) 819 && ( trueFlags == testFlags ) 820 ) { 821 /* no problem */ 822 } 823 else { 824 ++errorCount; 825 writeErrorFound( 10000 - count ); 826 writeInput_a_int64(); 827 fputs( " ", stdout ); 828 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags ); 829 fflush( stdout ); 830 if ( errorCount == maxErrorCount ) goto exit; 831 } 832 } 833 } 834 exit: 835 writeTestsPerformed( 10000 - count ); 836 837} 838 839#endif 840 841#ifdef FLOAT128 842 843void 844 test_a_int64_z_float128( 845 float128 trueFunction( int64 ), float128 testFunction( int64 ) ) 846{ 847 int16 count; 848 float128 trueZ, testZ; 849 uint8 trueFlags, testFlags; 850 851 errorCount = 0; 852 tenthousandsCount = 0; 853 count = 10000; 854 testCases_initSequence( testCases_sequence_a_int64 ); 855 writeTestsTotal(); 856 while ( ! testCases_done || forever ) { 857 testCases_next(); 858 *trueFlagsPtr = 0; 859 trueZ = trueFunction( testCases_a_int64 ); 860 trueFlags = *trueFlagsPtr; 861 (void) testFlagsFunctionPtr(); 862 testZ = testFunction( testCases_a_int64 ); 863 testFlags = testFlagsFunctionPtr(); 864 --count; 865 if ( count == 0 ) { 866 checkEarlyExit(); 867 count = 10000; 868 } 869 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 870 if ( ! checkNaNs 871 && float128_isNaN( trueZ ) 872 && float128_isNaN( testZ ) 873 && ! float128_is_signaling_nan( testZ ) 874 && ( trueFlags == testFlags ) 875 ) { 876 /* no problem */ 877 } 878 else { 879 ++errorCount; 880 writeErrorFound( 10000 - count ); 881 writeInput_a_int64(); 882 fputs( "\n\t", stdout ); 883 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags ); 884 fflush( stdout ); 885 if ( errorCount == maxErrorCount ) goto exit; 886 } 887 } 888 } 889 exit: 890 writeTestsPerformed( 10000 - count ); 891 892} 893 894#endif 895 896#endif 897 898void 899 test_a_float32_z_int32( 900 int32 trueFunction( float32 ), int32 testFunction( float32 ) ) 901{ 902 int16 count; 903 int32 trueZ, testZ; 904 uint8 trueFlags, testFlags; 905 906 errorCount = 0; 907 tenthousandsCount = 0; 908 count = 10000; 909 testCases_initSequence( testCases_sequence_a_float32 ); 910 writeTestsTotal(); 911 while ( ! testCases_done || forever ) { 912 testCases_next(); 913 *trueFlagsPtr = 0; 914 trueZ = trueFunction( testCases_a_float32 ); 915 trueFlags = *trueFlagsPtr; 916 (void) testFlagsFunctionPtr(); 917 testZ = testFunction( testCases_a_float32 ); 918 testFlags = testFlagsFunctionPtr(); 919 --count; 920 if ( count == 0 ) { 921 checkEarlyExit(); 922 count = 10000; 923 } 924 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 925 if ( ! checkNaNs 926 && float32_is_signaling_nan( testCases_a_float32 ) ) { 927 trueFlags |= float_flag_invalid; 928 } 929 if ( ( trueZ == 0x7FFFFFFF ) 930 && ( ( testZ == 0x7FFFFFFF ) 931 || ( testZ == (sbits32) 0x80000000 ) ) 932 && ( trueFlags == float_flag_invalid ) 933 && ( testFlags == float_flag_invalid ) 934 ) { 935 /* no problem */ 936 } 937 else { 938 ++errorCount; 939 writeErrorFound( 10000 - count ); 940 writeInput_a_float32(); 941 fputs( " ", stdout ); 942 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags ); 943 fflush( stdout ); 944 if ( errorCount == maxErrorCount ) goto exit; 945 } 946 } 947 } 948 exit: 949 writeTestsPerformed( 10000 - count ); 950 951} 952 953#ifdef BITS64 954 955void 956 test_a_float32_z_int64( 957 int64 trueFunction( float32 ), int64 testFunction( float32 ) ) 958{ 959 int16 count; 960 int64 trueZ, testZ; 961 uint8 trueFlags, testFlags; 962 963 errorCount = 0; 964 tenthousandsCount = 0; 965 count = 10000; 966 testCases_initSequence( testCases_sequence_a_float32 ); 967 writeTestsTotal(); 968 while ( ! testCases_done || forever ) { 969 testCases_next(); 970 *trueFlagsPtr = 0; 971 trueZ = trueFunction( testCases_a_float32 ); 972 trueFlags = *trueFlagsPtr; 973 (void) testFlagsFunctionPtr(); 974 testZ = testFunction( testCases_a_float32 ); 975 testFlags = testFlagsFunctionPtr(); 976 --count; 977 if ( count == 0 ) { 978 checkEarlyExit(); 979 count = 10000; 980 } 981 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 982 if ( ! checkNaNs 983 && float32_is_signaling_nan( testCases_a_float32 ) ) { 984 trueFlags |= float_flag_invalid; 985 } 986 if ( ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) ) 987 && ( ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) ) 988 || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) ) 989 && ( trueFlags == float_flag_invalid ) 990 && ( testFlags == float_flag_invalid ) 991 ) { 992 /* no problem */ 993 } 994 else { 995 ++errorCount; 996 writeErrorFound( 10000 - count ); 997 writeInput_a_float32(); 998 fputs( " ", stdout ); 999 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags ); 1000 fflush( stdout ); 1001 if ( errorCount == maxErrorCount ) goto exit; 1002 } 1003 } 1004 } 1005 exit: 1006 writeTestsPerformed( 10000 - count ); 1007 1008} 1009 1010#endif 1011 1012void 1013 test_a_float32_z_float64( 1014 float64 trueFunction( float32 ), float64 testFunction( float32 ) ) 1015{ 1016 int16 count; 1017 float64 trueZ, testZ; 1018 uint8 trueFlags, testFlags; 1019 1020 errorCount = 0; 1021 tenthousandsCount = 0; 1022 count = 10000; 1023 testCases_initSequence( testCases_sequence_a_float32 ); 1024 writeTestsTotal(); 1025 while ( ! testCases_done || forever ) { 1026 testCases_next(); 1027 *trueFlagsPtr = 0; 1028 trueZ = trueFunction( testCases_a_float32 ); 1029 trueFlags = *trueFlagsPtr; 1030 (void) testFlagsFunctionPtr(); 1031 testZ = testFunction( testCases_a_float32 ); 1032 testFlags = testFlagsFunctionPtr(); 1033 --count; 1034 if ( count == 0 ) { 1035 checkEarlyExit(); 1036 count = 10000; 1037 } 1038 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 1039 if ( ! checkNaNs 1040 && float32_is_signaling_nan( testCases_a_float32 ) ) { 1041 trueFlags |= float_flag_invalid; 1042 } 1043 if ( ! checkNaNs 1044 && float64_isNaN( trueZ ) 1045 && float64_isNaN( testZ ) 1046 && ! float64_is_signaling_nan( testZ ) 1047 && ( trueFlags == testFlags ) 1048 ) { 1049 /* no problem */ 1050 } 1051 else { 1052 ++errorCount; 1053 writeErrorFound( 10000 - count ); 1054 writeInput_a_float32(); 1055 fputs( " ", stdout ); 1056 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags ); 1057 fflush( stdout ); 1058 if ( errorCount == maxErrorCount ) goto exit; 1059 } 1060 } 1061 } 1062 exit: 1063 writeTestsPerformed( 10000 - count ); 1064 1065} 1066 1067#ifdef FLOATX80 1068 1069void 1070 test_a_float32_z_floatx80( 1071 floatx80 trueFunction( float32 ), floatx80 testFunction( float32 ) ) 1072{ 1073 int16 count; 1074 floatx80 trueZ, testZ; 1075 uint8 trueFlags, testFlags; 1076 1077 errorCount = 0; 1078 tenthousandsCount = 0; 1079 count = 10000; 1080 testCases_initSequence( testCases_sequence_a_float32 ); 1081 writeTestsTotal(); 1082 while ( ! testCases_done || forever ) { 1083 testCases_next(); 1084 *trueFlagsPtr = 0; 1085 trueZ = trueFunction( testCases_a_float32 ); 1086 trueFlags = *trueFlagsPtr; 1087 (void) testFlagsFunctionPtr(); 1088 testZ = testFunction( testCases_a_float32 ); 1089 testFlags = testFlagsFunctionPtr(); 1090 --count; 1091 if ( count == 0 ) { 1092 checkEarlyExit(); 1093 count = 10000; 1094 } 1095 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 1096 if ( ! checkNaNs 1097 && float32_is_signaling_nan( testCases_a_float32 ) ) { 1098 trueFlags |= float_flag_invalid; 1099 } 1100 if ( ! checkNaNs 1101 && floatx80_isNaN( trueZ ) 1102 && floatx80_isNaN( testZ ) 1103 && ! floatx80_is_signaling_nan( testZ ) 1104 && ( trueFlags == testFlags ) 1105 ) { 1106 /* no problem */ 1107 } 1108 else { 1109 ++errorCount; 1110 writeErrorFound( 10000 - count ); 1111 writeInput_a_float32(); 1112 fputs( "\n\t", stdout ); 1113 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags ); 1114 fflush( stdout ); 1115 if ( errorCount == maxErrorCount ) goto exit; 1116 } 1117 } 1118 } 1119 exit: 1120 writeTestsPerformed( 10000 - count ); 1121 1122} 1123 1124#endif 1125 1126#ifdef FLOAT128 1127 1128void 1129 test_a_float32_z_float128( 1130 float128 trueFunction( float32 ), float128 testFunction( float32 ) ) 1131{ 1132 int16 count; 1133 float128 trueZ, testZ; 1134 uint8 trueFlags, testFlags; 1135 1136 errorCount = 0; 1137 tenthousandsCount = 0; 1138 count = 10000; 1139 testCases_initSequence( testCases_sequence_a_float32 ); 1140 writeTestsTotal(); 1141 while ( ! testCases_done || forever ) { 1142 testCases_next(); 1143 *trueFlagsPtr = 0; 1144 trueZ = trueFunction( testCases_a_float32 ); 1145 trueFlags = *trueFlagsPtr; 1146 (void) testFlagsFunctionPtr(); 1147 testZ = testFunction( testCases_a_float32 ); 1148 testFlags = testFlagsFunctionPtr(); 1149 --count; 1150 if ( count == 0 ) { 1151 checkEarlyExit(); 1152 count = 10000; 1153 } 1154 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 1155 if ( ! checkNaNs 1156 && float32_is_signaling_nan( testCases_a_float32 ) ) { 1157 trueFlags |= float_flag_invalid; 1158 } 1159 if ( ! checkNaNs 1160 && float128_isNaN( trueZ ) 1161 && float128_isNaN( testZ ) 1162 && ! float128_is_signaling_nan( testZ ) 1163 && ( trueFlags == testFlags ) 1164 ) { 1165 /* no problem */ 1166 } 1167 else { 1168 ++errorCount; 1169 writeErrorFound( 10000 - count ); 1170 writeInput_a_float32(); 1171 fputs( "\n\t", stdout ); 1172 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags ); 1173 fflush( stdout ); 1174 if ( errorCount == maxErrorCount ) goto exit; 1175 } 1176 } 1177 } 1178 exit: 1179 writeTestsPerformed( 10000 - count ); 1180 1181} 1182 1183#endif 1184 1185void 1186 test_az_float32( 1187 float32 trueFunction( float32 ), float32 testFunction( float32 ) ) 1188{ 1189 int16 count; 1190 float32 trueZ, testZ; 1191 uint8 trueFlags, testFlags; 1192 1193 errorCount = 0; 1194 tenthousandsCount = 0; 1195 count = 10000; 1196 testCases_initSequence( testCases_sequence_a_float32 ); 1197 writeTestsTotal(); 1198 while ( ! testCases_done || forever ) { 1199 testCases_next(); 1200 *trueFlagsPtr = 0; 1201 trueZ = trueFunction( testCases_a_float32 ); 1202 trueFlags = *trueFlagsPtr; 1203 (void) testFlagsFunctionPtr(); 1204 testZ = testFunction( testCases_a_float32 ); 1205 testFlags = testFlagsFunctionPtr(); 1206 --count; 1207 if ( count == 0 ) { 1208 checkEarlyExit(); 1209 count = 10000; 1210 } 1211 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1212 if ( ! checkNaNs 1213 && float32_is_signaling_nan( testCases_a_float32 ) ) { 1214 trueFlags |= float_flag_invalid; 1215 } 1216 if ( ! checkNaNs 1217 && float32_isNaN( trueZ ) 1218 && float32_isNaN( testZ ) 1219 && ! float32_is_signaling_nan( testZ ) 1220 && ( trueFlags == testFlags ) 1221 ) { 1222 /* no problem */ 1223 } 1224 else { 1225 ++errorCount; 1226 writeErrorFound( 10000 - count ); 1227 writeInput_a_float32(); 1228 fputs( " ", stdout ); 1229 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags ); 1230 fflush( stdout ); 1231 if ( errorCount == maxErrorCount ) goto exit; 1232 } 1233 } 1234 } 1235 exit: 1236 writeTestsPerformed( 10000 - count ); 1237 1238} 1239 1240void 1241 test_ab_float32_z_flag( 1242 flag trueFunction( float32, float32 ), 1243 flag testFunction( float32, float32 ) 1244 ) 1245{ 1246 int16 count; 1247 flag trueZ, testZ; 1248 uint8 trueFlags, testFlags; 1249 1250 errorCount = 0; 1251 tenthousandsCount = 0; 1252 count = 10000; 1253 testCases_initSequence( testCases_sequence_ab_float32 ); 1254 writeTestsTotal(); 1255 while ( ! testCases_done || forever ) { 1256 testCases_next(); 1257 *trueFlagsPtr = 0; 1258 trueZ = trueFunction( testCases_a_float32, testCases_b_float32 ); 1259 trueFlags = *trueFlagsPtr; 1260 (void) testFlagsFunctionPtr(); 1261 testZ = testFunction( testCases_a_float32, testCases_b_float32 ); 1262 testFlags = testFlagsFunctionPtr(); 1263 --count; 1264 if ( count == 0 ) { 1265 checkEarlyExit(); 1266 count = 10000; 1267 } 1268 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1269 if ( ! checkNaNs 1270 && ( float32_is_signaling_nan( testCases_a_float32 ) 1271 || float32_is_signaling_nan( testCases_b_float32 ) ) 1272 ) { 1273 trueFlags |= float_flag_invalid; 1274 } 1275 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1276 ++errorCount; 1277 writeErrorFound( 10000 - count ); 1278 writeInputs_ab_float32(); 1279 fputs( " ", stdout ); 1280 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags ); 1281 fflush( stdout ); 1282 if ( errorCount == maxErrorCount ) goto exit; 1283 } 1284 } 1285 } 1286 exit: 1287 writeTestsPerformed( 10000 - count ); 1288 return; 1289 1290} 1291 1292void 1293 test_abz_float32( 1294 float32 trueFunction( float32, float32 ), 1295 float32 testFunction( float32, float32 ) 1296 ) 1297{ 1298 int16 count; 1299 float32 trueZ, testZ; 1300 uint8 trueFlags, testFlags; 1301 1302 errorCount = 0; 1303 tenthousandsCount = 0; 1304 count = 10000; 1305 testCases_initSequence( testCases_sequence_ab_float32 ); 1306 writeTestsTotal(); 1307 while ( ! testCases_done || forever ) { 1308 testCases_next(); 1309 *trueFlagsPtr = 0; 1310 trueZ = trueFunction( testCases_a_float32, testCases_b_float32 ); 1311 trueFlags = *trueFlagsPtr; 1312 (void) testFlagsFunctionPtr(); 1313 testZ = testFunction( testCases_a_float32, testCases_b_float32 ); 1314 testFlags = testFlagsFunctionPtr(); 1315 --count; 1316 if ( count == 0 ) { 1317 checkEarlyExit(); 1318 count = 10000; 1319 } 1320 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1321 if ( ! checkNaNs 1322 && ( float32_is_signaling_nan( testCases_a_float32 ) 1323 || float32_is_signaling_nan( testCases_b_float32 ) ) 1324 ) { 1325 trueFlags |= float_flag_invalid; 1326 } 1327 if ( ! checkNaNs 1328 && float32_isNaN( trueZ ) 1329 && float32_isNaN( testZ ) 1330 && ! float32_is_signaling_nan( testZ ) 1331 && ( trueFlags == testFlags ) 1332 ) { 1333 /* no problem */ 1334 } 1335 else { 1336 ++errorCount; 1337 writeErrorFound( 10000 - count ); 1338 writeInputs_ab_float32(); 1339 fputs( " ", stdout ); 1340 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags ); 1341 fflush( stdout ); 1342 if ( errorCount == maxErrorCount ) goto exit; 1343 } 1344 } 1345 } 1346 exit: 1347 writeTestsPerformed( 10000 - count ); 1348 return; 1349 1350} 1351 1352void 1353 test_a_float64_z_int32( 1354 int32 trueFunction( float64 ), int32 testFunction( float64 ) ) 1355{ 1356 int16 count; 1357 int32 trueZ, testZ; 1358 uint8 trueFlags, testFlags; 1359 1360 errorCount = 0; 1361 tenthousandsCount = 0; 1362 count = 10000; 1363 testCases_initSequence( testCases_sequence_a_float64 ); 1364 writeTestsTotal(); 1365 while ( ! testCases_done || forever ) { 1366 testCases_next(); 1367 *trueFlagsPtr = 0; 1368 trueZ = trueFunction( testCases_a_float64 ); 1369 trueFlags = *trueFlagsPtr; 1370 (void) testFlagsFunctionPtr(); 1371 testZ = testFunction( testCases_a_float64 ); 1372 testFlags = testFlagsFunctionPtr(); 1373 --count; 1374 if ( count == 0 ) { 1375 checkEarlyExit(); 1376 count = 10000; 1377 } 1378 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1379 if ( ! checkNaNs 1380 && float64_is_signaling_nan( testCases_a_float64 ) ) { 1381 trueFlags |= float_flag_invalid; 1382 } 1383 if ( ( trueZ == 0x7FFFFFFF ) 1384 && ( ( testZ == 0x7FFFFFFF ) 1385 || ( testZ == (sbits32) 0x80000000 ) ) 1386 && ( trueFlags == float_flag_invalid ) 1387 && ( testFlags == float_flag_invalid ) 1388 ) { 1389 /* no problem */ 1390 } 1391 else { 1392 ++errorCount; 1393 writeErrorFound( 10000 - count ); 1394 writeInput_a_float64(); 1395 fputs( " ", stdout ); 1396 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags ); 1397 fflush( stdout ); 1398 if ( errorCount == maxErrorCount ) goto exit; 1399 } 1400 } 1401 } 1402 exit: 1403 writeTestsPerformed( 10000 - count ); 1404 1405} 1406 1407#ifdef BITS64 1408 1409void 1410 test_a_float64_z_int64( 1411 int64 trueFunction( float64 ), int64 testFunction( float64 ) ) 1412{ 1413 int16 count; 1414 int64 trueZ, testZ; 1415 uint8 trueFlags, testFlags; 1416 1417 errorCount = 0; 1418 tenthousandsCount = 0; 1419 count = 10000; 1420 testCases_initSequence( testCases_sequence_a_float64 ); 1421 writeTestsTotal(); 1422 while ( ! testCases_done || forever ) { 1423 testCases_next(); 1424 *trueFlagsPtr = 0; 1425 trueZ = trueFunction( testCases_a_float64 ); 1426 trueFlags = *trueFlagsPtr; 1427 (void) testFlagsFunctionPtr(); 1428 testZ = testFunction( testCases_a_float64 ); 1429 testFlags = testFlagsFunctionPtr(); 1430 --count; 1431 if ( count == 0 ) { 1432 checkEarlyExit(); 1433 count = 10000; 1434 } 1435 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1436 if ( ! checkNaNs 1437 && float64_is_signaling_nan( testCases_a_float64 ) ) { 1438 trueFlags |= float_flag_invalid; 1439 } 1440 if ( ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) ) 1441 && ( ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) ) 1442 || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) ) 1443 && ( trueFlags == float_flag_invalid ) 1444 && ( testFlags == float_flag_invalid ) 1445 ) { 1446 /* no problem */ 1447 } 1448 else { 1449 ++errorCount; 1450 writeErrorFound( 10000 - count ); 1451 writeInput_a_float64(); 1452 fputs( " ", stdout ); 1453 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags ); 1454 fflush( stdout ); 1455 if ( errorCount == maxErrorCount ) goto exit; 1456 } 1457 } 1458 } 1459 exit: 1460 writeTestsPerformed( 10000 - count ); 1461 1462} 1463 1464#endif 1465 1466void 1467 test_a_float64_z_float32( 1468 float32 trueFunction( float64 ), float32 testFunction( float64 ) ) 1469{ 1470 int16 count; 1471 float32 trueZ, testZ; 1472 uint8 trueFlags, testFlags; 1473 1474 errorCount = 0; 1475 tenthousandsCount = 0; 1476 count = 10000; 1477 testCases_initSequence( testCases_sequence_a_float64 ); 1478 writeTestsTotal(); 1479 while ( ! testCases_done || forever ) { 1480 testCases_next(); 1481 *trueFlagsPtr = 0; 1482 trueZ = trueFunction( testCases_a_float64 ); 1483 trueFlags = *trueFlagsPtr; 1484 (void) testFlagsFunctionPtr(); 1485 testZ = testFunction( testCases_a_float64 ); 1486 testFlags = testFlagsFunctionPtr(); 1487 --count; 1488 if ( count == 0 ) { 1489 checkEarlyExit(); 1490 count = 10000; 1491 } 1492 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1493 if ( ! checkNaNs 1494 && float64_is_signaling_nan( testCases_a_float64 ) ) { 1495 trueFlags |= float_flag_invalid; 1496 } 1497 if ( ! checkNaNs 1498 && float32_isNaN( trueZ ) 1499 && float32_isNaN( testZ ) 1500 && ! float32_is_signaling_nan( testZ ) 1501 && ( trueFlags == testFlags ) 1502 ) { 1503 /* no problem */ 1504 } 1505 else { 1506 ++errorCount; 1507 writeErrorFound( 10000 - count ); 1508 writeInput_a_float64(); 1509 fputs( " ", stdout ); 1510 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags ); 1511 fflush( stdout ); 1512 if ( errorCount == maxErrorCount ) goto exit; 1513 } 1514 } 1515 } 1516 exit: 1517 writeTestsPerformed( 10000 - count ); 1518 1519} 1520 1521#ifdef FLOATX80 1522 1523void 1524 test_a_float64_z_floatx80( 1525 floatx80 trueFunction( float64 ), floatx80 testFunction( float64 ) ) 1526{ 1527 int16 count; 1528 floatx80 trueZ, testZ; 1529 uint8 trueFlags, testFlags; 1530 1531 errorCount = 0; 1532 tenthousandsCount = 0; 1533 count = 10000; 1534 testCases_initSequence( testCases_sequence_a_float64 ); 1535 writeTestsTotal(); 1536 while ( ! testCases_done || forever ) { 1537 testCases_next(); 1538 *trueFlagsPtr = 0; 1539 trueZ = trueFunction( testCases_a_float64 ); 1540 trueFlags = *trueFlagsPtr; 1541 (void) testFlagsFunctionPtr(); 1542 testZ = testFunction( testCases_a_float64 ); 1543 testFlags = testFlagsFunctionPtr(); 1544 --count; 1545 if ( count == 0 ) { 1546 checkEarlyExit(); 1547 count = 10000; 1548 } 1549 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 1550 if ( ! checkNaNs 1551 && float64_is_signaling_nan( testCases_a_float64 ) ) { 1552 trueFlags |= float_flag_invalid; 1553 } 1554 if ( ! checkNaNs 1555 && floatx80_isNaN( trueZ ) 1556 && floatx80_isNaN( testZ ) 1557 && ! floatx80_is_signaling_nan( testZ ) 1558 && ( trueFlags == testFlags ) 1559 ) { 1560 /* no problem */ 1561 } 1562 else { 1563 ++errorCount; 1564 writeErrorFound( 10000 - count ); 1565 writeInput_a_float64(); 1566 fputs( "\n\t", stdout ); 1567 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags ); 1568 fflush( stdout ); 1569 if ( errorCount == maxErrorCount ) goto exit; 1570 } 1571 } 1572 } 1573 exit: 1574 writeTestsPerformed( 10000 - count ); 1575 1576} 1577 1578#endif 1579 1580#ifdef FLOAT128 1581 1582void 1583 test_a_float64_z_float128( 1584 float128 trueFunction( float64 ), float128 testFunction( float64 ) ) 1585{ 1586 int16 count; 1587 float128 trueZ, testZ; 1588 uint8 trueFlags, testFlags; 1589 1590 errorCount = 0; 1591 tenthousandsCount = 0; 1592 count = 10000; 1593 testCases_initSequence( testCases_sequence_a_float64 ); 1594 writeTestsTotal(); 1595 while ( ! testCases_done || forever ) { 1596 testCases_next(); 1597 *trueFlagsPtr = 0; 1598 trueZ = trueFunction( testCases_a_float64 ); 1599 trueFlags = *trueFlagsPtr; 1600 (void) testFlagsFunctionPtr(); 1601 testZ = testFunction( testCases_a_float64 ); 1602 testFlags = testFlagsFunctionPtr(); 1603 --count; 1604 if ( count == 0 ) { 1605 checkEarlyExit(); 1606 count = 10000; 1607 } 1608 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 1609 if ( ! checkNaNs 1610 && float64_is_signaling_nan( testCases_a_float64 ) ) { 1611 trueFlags |= float_flag_invalid; 1612 } 1613 if ( ! checkNaNs 1614 && float128_isNaN( trueZ ) 1615 && float128_isNaN( testZ ) 1616 && ! float128_is_signaling_nan( testZ ) 1617 && ( trueFlags == testFlags ) 1618 ) { 1619 /* no problem */ 1620 } 1621 else { 1622 ++errorCount; 1623 writeErrorFound( 10000 - count ); 1624 writeInput_a_float64(); 1625 fputs( "\n\t", stdout ); 1626 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags ); 1627 fflush( stdout ); 1628 if ( errorCount == maxErrorCount ) goto exit; 1629 } 1630 } 1631 } 1632 exit: 1633 writeTestsPerformed( 10000 - count ); 1634 1635} 1636 1637#endif 1638 1639void 1640 test_az_float64( 1641 float64 trueFunction( float64 ), float64 testFunction( float64 ) ) 1642{ 1643 int16 count; 1644 float64 trueZ, testZ; 1645 uint8 trueFlags, testFlags; 1646 1647 errorCount = 0; 1648 tenthousandsCount = 0; 1649 count = 10000; 1650 testCases_initSequence( testCases_sequence_a_float64 ); 1651 writeTestsTotal(); 1652 while ( ! testCases_done || forever ) { 1653 testCases_next(); 1654 *trueFlagsPtr = 0; 1655 trueZ = trueFunction( testCases_a_float64 ); 1656 trueFlags = *trueFlagsPtr; 1657 (void) testFlagsFunctionPtr(); 1658 testZ = testFunction( testCases_a_float64 ); 1659 testFlags = testFlagsFunctionPtr(); 1660 --count; 1661 if ( count == 0 ) { 1662 checkEarlyExit(); 1663 count = 10000; 1664 } 1665 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 1666 if ( ! checkNaNs 1667 && float64_is_signaling_nan( testCases_a_float64 ) ) { 1668 trueFlags |= float_flag_invalid; 1669 } 1670 if ( ! checkNaNs 1671 && float64_isNaN( trueZ ) 1672 && float64_isNaN( testZ ) 1673 && ! float64_is_signaling_nan( testZ ) 1674 && ( trueFlags == testFlags ) 1675 ) { 1676 /* no problem */ 1677 } 1678 else { 1679 ++errorCount; 1680 writeErrorFound( 10000 - count ); 1681 writeInput_a_float64(); 1682 fputs( " ", stdout ); 1683 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags ); 1684 fflush( stdout ); 1685 if ( errorCount == maxErrorCount ) goto exit; 1686 } 1687 } 1688 } 1689 exit: 1690 writeTestsPerformed( 10000 - count ); 1691 1692} 1693 1694void 1695 test_ab_float64_z_flag( 1696 flag trueFunction( float64, float64 ), 1697 flag testFunction( float64, float64 ) 1698 ) 1699{ 1700 int16 count; 1701 flag trueZ, testZ; 1702 uint8 trueFlags, testFlags; 1703 1704 errorCount = 0; 1705 tenthousandsCount = 0; 1706 count = 10000; 1707 testCases_initSequence( testCases_sequence_ab_float64 ); 1708 writeTestsTotal(); 1709 while ( ! testCases_done || forever ) { 1710 testCases_next(); 1711 *trueFlagsPtr = 0; 1712 trueZ = trueFunction( testCases_a_float64, testCases_b_float64 ); 1713 trueFlags = *trueFlagsPtr; 1714 (void) testFlagsFunctionPtr(); 1715 testZ = testFunction( testCases_a_float64, testCases_b_float64 ); 1716 testFlags = testFlagsFunctionPtr(); 1717 --count; 1718 if ( count == 0 ) { 1719 checkEarlyExit(); 1720 count = 10000; 1721 } 1722 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1723 if ( ! checkNaNs 1724 && ( float64_is_signaling_nan( testCases_a_float64 ) 1725 || float64_is_signaling_nan( testCases_b_float64 ) ) 1726 ) { 1727 trueFlags |= float_flag_invalid; 1728 } 1729 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1730 ++errorCount; 1731 writeErrorFound( 10000 - count ); 1732 writeInputs_ab_float64(); 1733 fputs( " ", stdout ); 1734 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags ); 1735 fflush( stdout ); 1736 if ( errorCount == maxErrorCount ) goto exit; 1737 } 1738 } 1739 } 1740 exit: 1741 writeTestsPerformed( 10000 - count ); 1742 return; 1743 1744} 1745 1746void 1747 test_abz_float64( 1748 float64 trueFunction( float64, float64 ), 1749 float64 testFunction( float64, float64 ) 1750 ) 1751{ 1752 int16 count; 1753 float64 trueZ, testZ; 1754 uint8 trueFlags, testFlags; 1755 1756 errorCount = 0; 1757 tenthousandsCount = 0; 1758 count = 10000; 1759 testCases_initSequence( testCases_sequence_ab_float64 ); 1760 writeTestsTotal(); 1761 while ( ! testCases_done || forever ) { 1762 testCases_next(); 1763 *trueFlagsPtr = 0; 1764 trueZ = trueFunction( testCases_a_float64, testCases_b_float64 ); 1765 trueFlags = *trueFlagsPtr; 1766 (void) testFlagsFunctionPtr(); 1767 testZ = testFunction( testCases_a_float64, testCases_b_float64 ); 1768 testFlags = testFlagsFunctionPtr(); 1769 --count; 1770 if ( count == 0 ) { 1771 checkEarlyExit(); 1772 count = 10000; 1773 } 1774 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 1775 if ( ! checkNaNs 1776 && ( float64_is_signaling_nan( testCases_a_float64 ) 1777 || float64_is_signaling_nan( testCases_b_float64 ) ) 1778 ) { 1779 trueFlags |= float_flag_invalid; 1780 } 1781 if ( ! checkNaNs 1782 && float64_isNaN( trueZ ) 1783 && float64_isNaN( testZ ) 1784 && ! float64_is_signaling_nan( testZ ) 1785 && ( trueFlags == testFlags ) 1786 ) { 1787 /* no problem */ 1788 } 1789 else { 1790 ++errorCount; 1791 writeErrorFound( 10000 - count ); 1792 writeInputs_ab_float64(); 1793 fputs( "\n\t", stdout ); 1794 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags ); 1795 fflush( stdout ); 1796 if ( errorCount == maxErrorCount ) goto exit; 1797 } 1798 } 1799 } 1800 exit: 1801 writeTestsPerformed( 10000 - count ); 1802 return; 1803 1804} 1805 1806#ifdef FLOATX80 1807 1808void 1809 test_a_floatx80_z_int32( 1810 int32 trueFunction( floatx80 ), int32 testFunction( floatx80 ) ) 1811{ 1812 int16 count; 1813 int32 trueZ, testZ; 1814 uint8 trueFlags, testFlags; 1815 1816 errorCount = 0; 1817 tenthousandsCount = 0; 1818 count = 10000; 1819 testCases_initSequence( testCases_sequence_a_floatx80 ); 1820 writeTestsTotal(); 1821 while ( ! testCases_done || forever ) { 1822 testCases_next(); 1823 *trueFlagsPtr = 0; 1824 trueZ = trueFunction( testCases_a_floatx80 ); 1825 trueFlags = *trueFlagsPtr; 1826 (void) testFlagsFunctionPtr(); 1827 testZ = testFunction( testCases_a_floatx80 ); 1828 testFlags = testFlagsFunctionPtr(); 1829 --count; 1830 if ( count == 0 ) { 1831 checkEarlyExit(); 1832 count = 10000; 1833 } 1834 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1835 if ( ! checkNaNs 1836 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) { 1837 trueFlags |= float_flag_invalid; 1838 } 1839 if ( ( trueZ == 0x7FFFFFFF ) 1840 && ( ( testZ == 0x7FFFFFFF ) 1841 || ( testZ == (sbits32) 0x80000000 ) ) 1842 && ( trueFlags == float_flag_invalid ) 1843 && ( testFlags == float_flag_invalid ) 1844 ) { 1845 /* no problem */ 1846 } 1847 else { 1848 ++errorCount; 1849 writeErrorFound( 10000 - count ); 1850 writeInput_a_floatx80(); 1851 fputs( " ", stdout ); 1852 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags ); 1853 fflush( stdout ); 1854 if ( errorCount == maxErrorCount ) goto exit; 1855 } 1856 } 1857 } 1858 exit: 1859 writeTestsPerformed( 10000 - count ); 1860 1861} 1862 1863#ifdef BITS64 1864 1865void 1866 test_a_floatx80_z_int64( 1867 int64 trueFunction( floatx80 ), int64 testFunction( floatx80 ) ) 1868{ 1869 int16 count; 1870 int64 trueZ, testZ; 1871 uint8 trueFlags, testFlags; 1872 1873 errorCount = 0; 1874 tenthousandsCount = 0; 1875 count = 10000; 1876 testCases_initSequence( testCases_sequence_a_floatx80 ); 1877 writeTestsTotal(); 1878 while ( ! testCases_done || forever ) { 1879 testCases_next(); 1880 *trueFlagsPtr = 0; 1881 trueZ = trueFunction( testCases_a_floatx80 ); 1882 trueFlags = *trueFlagsPtr; 1883 (void) testFlagsFunctionPtr(); 1884 testZ = testFunction( testCases_a_floatx80 ); 1885 testFlags = testFlagsFunctionPtr(); 1886 --count; 1887 if ( count == 0 ) { 1888 checkEarlyExit(); 1889 count = 10000; 1890 } 1891 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1892 if ( ! checkNaNs 1893 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) { 1894 trueFlags |= float_flag_invalid; 1895 } 1896 if ( ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) ) 1897 && ( ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) ) 1898 || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) ) 1899 && ( trueFlags == float_flag_invalid ) 1900 && ( testFlags == float_flag_invalid ) 1901 ) { 1902 /* no problem */ 1903 } 1904 else { 1905 ++errorCount; 1906 writeErrorFound( 10000 - count ); 1907 writeInput_a_floatx80(); 1908 fputs( " ", stdout ); 1909 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags ); 1910 fflush( stdout ); 1911 if ( errorCount == maxErrorCount ) goto exit; 1912 } 1913 } 1914 } 1915 exit: 1916 writeTestsPerformed( 10000 - count ); 1917 1918} 1919 1920#endif 1921 1922void 1923 test_a_floatx80_z_float32( 1924 float32 trueFunction( floatx80 ), float32 testFunction( floatx80 ) ) 1925{ 1926 int16 count; 1927 float32 trueZ, testZ; 1928 uint8 trueFlags, testFlags; 1929 1930 errorCount = 0; 1931 tenthousandsCount = 0; 1932 count = 10000; 1933 testCases_initSequence( testCases_sequence_a_floatx80 ); 1934 writeTestsTotal(); 1935 while ( ! testCases_done || forever ) { 1936 testCases_next(); 1937 *trueFlagsPtr = 0; 1938 trueZ = trueFunction( testCases_a_floatx80 ); 1939 trueFlags = *trueFlagsPtr; 1940 (void) testFlagsFunctionPtr(); 1941 testZ = testFunction( testCases_a_floatx80 ); 1942 testFlags = testFlagsFunctionPtr(); 1943 --count; 1944 if ( count == 0 ) { 1945 checkEarlyExit(); 1946 count = 10000; 1947 } 1948 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 1949 if ( ! checkNaNs 1950 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) { 1951 trueFlags |= float_flag_invalid; 1952 } 1953 if ( ! checkNaNs 1954 && float32_isNaN( trueZ ) 1955 && float32_isNaN( testZ ) 1956 && ! float32_is_signaling_nan( testZ ) 1957 && ( trueFlags == testFlags ) 1958 ) { 1959 /* no problem */ 1960 } 1961 else { 1962 ++errorCount; 1963 writeErrorFound( 10000 - count ); 1964 writeInput_a_floatx80(); 1965 fputs( " ", stdout ); 1966 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags ); 1967 fflush( stdout ); 1968 if ( errorCount == maxErrorCount ) goto exit; 1969 } 1970 } 1971 } 1972 exit: 1973 writeTestsPerformed( 10000 - count ); 1974 1975} 1976 1977void 1978 test_a_floatx80_z_float64( 1979 float64 trueFunction( floatx80 ), float64 testFunction( floatx80 ) ) 1980{ 1981 int16 count; 1982 float64 trueZ, testZ; 1983 uint8 trueFlags, testFlags; 1984 1985 errorCount = 0; 1986 tenthousandsCount = 0; 1987 count = 10000; 1988 testCases_initSequence( testCases_sequence_a_floatx80 ); 1989 writeTestsTotal(); 1990 while ( ! testCases_done || forever ) { 1991 testCases_next(); 1992 *trueFlagsPtr = 0; 1993 trueZ = trueFunction( testCases_a_floatx80 ); 1994 trueFlags = *trueFlagsPtr; 1995 (void) testFlagsFunctionPtr(); 1996 testZ = testFunction( testCases_a_floatx80 ); 1997 testFlags = testFlagsFunctionPtr(); 1998 --count; 1999 if ( count == 0 ) { 2000 checkEarlyExit(); 2001 count = 10000; 2002 } 2003 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 2004 if ( ! checkNaNs 2005 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) { 2006 trueFlags |= float_flag_invalid; 2007 } 2008 if ( ! checkNaNs 2009 && float64_isNaN( trueZ ) 2010 && float64_isNaN( testZ ) 2011 && ! float64_is_signaling_nan( testZ ) 2012 && ( trueFlags == testFlags ) 2013 ) { 2014 /* no problem */ 2015 } 2016 else { 2017 ++errorCount; 2018 writeErrorFound( 10000 - count ); 2019 writeInput_a_floatx80(); 2020 fputs( "\n\t", stdout ); 2021 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags ); 2022 fflush( stdout ); 2023 if ( errorCount == maxErrorCount ) goto exit; 2024 } 2025 } 2026 } 2027 exit: 2028 writeTestsPerformed( 10000 - count ); 2029 2030} 2031 2032#ifdef FLOAT128 2033 2034void 2035 test_a_floatx80_z_float128( 2036 float128 trueFunction( floatx80 ), float128 testFunction( floatx80 ) ) 2037{ 2038 int16 count; 2039 float128 trueZ, testZ; 2040 uint8 trueFlags, testFlags; 2041 2042 errorCount = 0; 2043 tenthousandsCount = 0; 2044 count = 10000; 2045 testCases_initSequence( testCases_sequence_a_floatx80 ); 2046 writeTestsTotal(); 2047 while ( ! testCases_done || forever ) { 2048 testCases_next(); 2049 *trueFlagsPtr = 0; 2050 trueZ = trueFunction( testCases_a_floatx80 ); 2051 trueFlags = *trueFlagsPtr; 2052 (void) testFlagsFunctionPtr(); 2053 testZ = testFunction( testCases_a_floatx80 ); 2054 testFlags = testFlagsFunctionPtr(); 2055 --count; 2056 if ( count == 0 ) { 2057 checkEarlyExit(); 2058 count = 10000; 2059 } 2060 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 2061 if ( ! checkNaNs 2062 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) { 2063 trueFlags |= float_flag_invalid; 2064 } 2065 if ( ! checkNaNs 2066 && float128_isNaN( trueZ ) 2067 && float128_isNaN( testZ ) 2068 && ! float128_is_signaling_nan( testZ ) 2069 && ( trueFlags == testFlags ) 2070 ) { 2071 /* no problem */ 2072 } 2073 else { 2074 ++errorCount; 2075 writeErrorFound( 10000 - count ); 2076 writeInput_a_floatx80(); 2077 fputs( "\n\t", stdout ); 2078 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags ); 2079 fflush( stdout ); 2080 if ( errorCount == maxErrorCount ) goto exit; 2081 } 2082 } 2083 } 2084 exit: 2085 writeTestsPerformed( 10000 - count ); 2086 2087} 2088 2089#endif 2090 2091void 2092 test_az_floatx80( 2093 floatx80 trueFunction( floatx80 ), floatx80 testFunction( floatx80 ) ) 2094{ 2095 int16 count; 2096 floatx80 trueZ, testZ; 2097 uint8 trueFlags, testFlags; 2098 2099 errorCount = 0; 2100 tenthousandsCount = 0; 2101 count = 10000; 2102 testCases_initSequence( testCases_sequence_a_floatx80 ); 2103 writeTestsTotal(); 2104 while ( ! testCases_done || forever ) { 2105 testCases_next(); 2106 *trueFlagsPtr = 0; 2107 trueZ = trueFunction( testCases_a_floatx80 ); 2108 trueFlags = *trueFlagsPtr; 2109 (void) testFlagsFunctionPtr(); 2110 testZ = testFunction( testCases_a_floatx80 ); 2111 testFlags = testFlagsFunctionPtr(); 2112 --count; 2113 if ( count == 0 ) { 2114 checkEarlyExit(); 2115 count = 10000; 2116 } 2117 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 2118 if ( ! checkNaNs 2119 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) { 2120 trueFlags |= float_flag_invalid; 2121 } 2122 if ( ! checkNaNs 2123 && floatx80_isNaN( trueZ ) 2124 && floatx80_isNaN( testZ ) 2125 && ! floatx80_is_signaling_nan( testZ ) 2126 && ( trueFlags == testFlags ) 2127 ) { 2128 /* no problem */ 2129 } 2130 else { 2131 ++errorCount; 2132 writeErrorFound( 10000 - count ); 2133 writeInput_a_floatx80(); 2134 fputs( "\n\t", stdout ); 2135 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags ); 2136 fflush( stdout ); 2137 if ( errorCount == maxErrorCount ) goto exit; 2138 } 2139 } 2140 } 2141 exit: 2142 writeTestsPerformed( 10000 - count ); 2143 2144} 2145 2146void 2147 test_ab_floatx80_z_flag( 2148 flag trueFunction( floatx80, floatx80 ), 2149 flag testFunction( floatx80, floatx80 ) 2150 ) 2151{ 2152 int16 count; 2153 flag trueZ, testZ; 2154 uint8 trueFlags, testFlags; 2155 2156 errorCount = 0; 2157 tenthousandsCount = 0; 2158 count = 10000; 2159 testCases_initSequence( testCases_sequence_ab_floatx80 ); 2160 writeTestsTotal(); 2161 while ( ! testCases_done || forever ) { 2162 testCases_next(); 2163 *trueFlagsPtr = 0; 2164 trueZ = trueFunction( testCases_a_floatx80, testCases_b_floatx80 ); 2165 trueFlags = *trueFlagsPtr; 2166 (void) testFlagsFunctionPtr(); 2167 testZ = testFunction( testCases_a_floatx80, testCases_b_floatx80 ); 2168 testFlags = testFlagsFunctionPtr(); 2169 --count; 2170 if ( count == 0 ) { 2171 checkEarlyExit(); 2172 count = 10000; 2173 } 2174 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 2175 if ( ! checkNaNs 2176 && ( floatx80_is_signaling_nan( testCases_a_floatx80 ) 2177 || floatx80_is_signaling_nan( testCases_b_floatx80 ) ) 2178 ) { 2179 trueFlags |= float_flag_invalid; 2180 } 2181 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 2182 ++errorCount; 2183 writeErrorFound( 10000 - count ); 2184 writeInputs_ab_floatx80(); 2185 fputs( " ", stdout ); 2186 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags ); 2187 fflush( stdout ); 2188 if ( errorCount == maxErrorCount ) goto exit; 2189 } 2190 } 2191 } 2192 exit: 2193 writeTestsPerformed( 10000 - count ); 2194 return; 2195 2196} 2197 2198void 2199 test_abz_floatx80( 2200 floatx80 trueFunction( floatx80, floatx80 ), 2201 floatx80 testFunction( floatx80, floatx80 ) 2202 ) 2203{ 2204 int16 count; 2205 floatx80 trueZ, testZ; 2206 uint8 trueFlags, testFlags; 2207 2208 errorCount = 0; 2209 tenthousandsCount = 0; 2210 count = 10000; 2211 testCases_initSequence( testCases_sequence_ab_floatx80 ); 2212 writeTestsTotal(); 2213 while ( ! testCases_done || forever ) { 2214 testCases_next(); 2215 *trueFlagsPtr = 0; 2216 trueZ = trueFunction( testCases_a_floatx80, testCases_b_floatx80 ); 2217 trueFlags = *trueFlagsPtr; 2218 (void) testFlagsFunctionPtr(); 2219 testZ = testFunction( testCases_a_floatx80, testCases_b_floatx80 ); 2220 testFlags = testFlagsFunctionPtr(); 2221 --count; 2222 if ( count == 0 ) { 2223 checkEarlyExit(); 2224 count = 10000; 2225 } 2226 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 2227 if ( ! checkNaNs 2228 && ( floatx80_is_signaling_nan( testCases_a_floatx80 ) 2229 || floatx80_is_signaling_nan( testCases_b_floatx80 ) ) 2230 ) { 2231 trueFlags |= float_flag_invalid; 2232 } 2233 if ( ! checkNaNs 2234 && floatx80_isNaN( trueZ ) 2235 && floatx80_isNaN( testZ ) 2236 && ! floatx80_is_signaling_nan( testZ ) 2237 && ( trueFlags == testFlags ) 2238 ) { 2239 /* no problem */ 2240 } 2241 else { 2242 ++errorCount; 2243 writeErrorFound( 10000 - count ); 2244 writeInputs_ab_floatx80(); 2245 fputs( "\n\t", stdout ); 2246 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags ); 2247 fflush( stdout ); 2248 if ( errorCount == maxErrorCount ) goto exit; 2249 } 2250 } 2251 } 2252 exit: 2253 writeTestsPerformed( 10000 - count ); 2254 return; 2255 2256} 2257 2258#endif 2259 2260#ifdef FLOAT128 2261 2262void 2263 test_a_float128_z_int32( 2264 int32 trueFunction( float128 ), int32 testFunction( float128 ) ) 2265{ 2266 int16 count; 2267 int32 trueZ, testZ; 2268 uint8 trueFlags, testFlags; 2269 2270 errorCount = 0; 2271 tenthousandsCount = 0; 2272 count = 10000; 2273 testCases_initSequence( testCases_sequence_a_float128 ); 2274 writeTestsTotal(); 2275 while ( ! testCases_done || forever ) { 2276 testCases_next(); 2277 *trueFlagsPtr = 0; 2278 trueZ = trueFunction( testCases_a_float128 ); 2279 trueFlags = *trueFlagsPtr; 2280 (void) testFlagsFunctionPtr(); 2281 testZ = testFunction( testCases_a_float128 ); 2282 testFlags = testFlagsFunctionPtr(); 2283 --count; 2284 if ( count == 0 ) { 2285 checkEarlyExit(); 2286 count = 10000; 2287 } 2288 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 2289 if ( ! checkNaNs 2290 && float128_is_signaling_nan( testCases_a_float128 ) ) { 2291 trueFlags |= float_flag_invalid; 2292 } 2293 if ( ( trueZ == 0x7FFFFFFF ) 2294 && ( ( testZ == 0x7FFFFFFF ) 2295 || ( testZ == (sbits32) 0x80000000 ) ) 2296 && ( trueFlags == float_flag_invalid ) 2297 && ( testFlags == float_flag_invalid ) 2298 ) { 2299 /* no problem */ 2300 } 2301 else { 2302 ++errorCount; 2303 writeErrorFound( 10000 - count ); 2304 writeInput_a_float128(); 2305 fputs( " ", stdout ); 2306 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags ); 2307 fflush( stdout ); 2308 if ( errorCount == maxErrorCount ) goto exit; 2309 } 2310 } 2311 } 2312 exit: 2313 writeTestsPerformed( 10000 - count ); 2314 2315} 2316 2317#ifdef BITS64 2318 2319void 2320 test_a_float128_z_int64( 2321 int64 trueFunction( float128 ), int64 testFunction( float128 ) ) 2322{ 2323 int16 count; 2324 int64 trueZ, testZ; 2325 uint8 trueFlags, testFlags; 2326 2327 errorCount = 0; 2328 tenthousandsCount = 0; 2329 count = 10000; 2330 testCases_initSequence( testCases_sequence_a_float128 ); 2331 writeTestsTotal(); 2332 while ( ! testCases_done || forever ) { 2333 testCases_next(); 2334 *trueFlagsPtr = 0; 2335 trueZ = trueFunction( testCases_a_float128 ); 2336 trueFlags = *trueFlagsPtr; 2337 (void) testFlagsFunctionPtr(); 2338 testZ = testFunction( testCases_a_float128 ); 2339 testFlags = testFlagsFunctionPtr(); 2340 --count; 2341 if ( count == 0 ) { 2342 checkEarlyExit(); 2343 count = 10000; 2344 } 2345 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 2346 if ( ! checkNaNs 2347 && float128_is_signaling_nan( testCases_a_float128 ) ) { 2348 trueFlags |= float_flag_invalid; 2349 } 2350 if ( ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) ) 2351 && ( ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) ) 2352 || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) ) 2353 && ( trueFlags == float_flag_invalid ) 2354 && ( testFlags == float_flag_invalid ) 2355 ) { 2356 /* no problem */ 2357 } 2358 else { 2359 ++errorCount; 2360 writeErrorFound( 10000 - count ); 2361 writeInput_a_float128(); 2362 fputs( "\n\t", stdout ); 2363 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags ); 2364 fflush( stdout ); 2365 if ( errorCount == maxErrorCount ) goto exit; 2366 } 2367 } 2368 } 2369 exit: 2370 writeTestsPerformed( 10000 - count ); 2371 2372} 2373 2374#endif 2375 2376void 2377 test_a_float128_z_float32( 2378 float32 trueFunction( float128 ), float32 testFunction( float128 ) ) 2379{ 2380 int16 count; 2381 float32 trueZ, testZ; 2382 uint8 trueFlags, testFlags; 2383 2384 errorCount = 0; 2385 tenthousandsCount = 0; 2386 count = 10000; 2387 testCases_initSequence( testCases_sequence_a_float128 ); 2388 writeTestsTotal(); 2389 while ( ! testCases_done || forever ) { 2390 testCases_next(); 2391 *trueFlagsPtr = 0; 2392 trueZ = trueFunction( testCases_a_float128 ); 2393 trueFlags = *trueFlagsPtr; 2394 (void) testFlagsFunctionPtr(); 2395 testZ = testFunction( testCases_a_float128 ); 2396 testFlags = testFlagsFunctionPtr(); 2397 --count; 2398 if ( count == 0 ) { 2399 checkEarlyExit(); 2400 count = 10000; 2401 } 2402 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 2403 if ( ! checkNaNs 2404 && float128_is_signaling_nan( testCases_a_float128 ) ) { 2405 trueFlags |= float_flag_invalid; 2406 } 2407 if ( ! checkNaNs 2408 && float32_isNaN( trueZ ) 2409 && float32_isNaN( testZ ) 2410 && ! float32_is_signaling_nan( testZ ) 2411 && ( trueFlags == testFlags ) 2412 ) { 2413 /* no problem */ 2414 } 2415 else { 2416 ++errorCount; 2417 writeErrorFound( 10000 - count ); 2418 writeInput_a_float128(); 2419 fputs( " ", stdout ); 2420 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags ); 2421 fflush( stdout ); 2422 if ( errorCount == maxErrorCount ) goto exit; 2423 } 2424 } 2425 } 2426 exit: 2427 writeTestsPerformed( 10000 - count ); 2428 2429} 2430 2431void 2432 test_a_float128_z_float64( 2433 float64 trueFunction( float128 ), float64 testFunction( float128 ) ) 2434{ 2435 int16 count; 2436 float64 trueZ, testZ; 2437 uint8 trueFlags, testFlags; 2438 2439 errorCount = 0; 2440 tenthousandsCount = 0; 2441 count = 10000; 2442 testCases_initSequence( testCases_sequence_a_float128 ); 2443 writeTestsTotal(); 2444 while ( ! testCases_done || forever ) { 2445 testCases_next(); 2446 *trueFlagsPtr = 0; 2447 trueZ = trueFunction( testCases_a_float128 ); 2448 trueFlags = *trueFlagsPtr; 2449 (void) testFlagsFunctionPtr(); 2450 testZ = testFunction( testCases_a_float128 ); 2451 testFlags = testFlagsFunctionPtr(); 2452 --count; 2453 if ( count == 0 ) { 2454 checkEarlyExit(); 2455 count = 10000; 2456 } 2457 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 2458 if ( ! checkNaNs 2459 && float128_is_signaling_nan( testCases_a_float128 ) ) { 2460 trueFlags |= float_flag_invalid; 2461 } 2462 if ( ! checkNaNs 2463 && float64_isNaN( trueZ ) 2464 && float64_isNaN( testZ ) 2465 && ! float64_is_signaling_nan( testZ ) 2466 && ( trueFlags == testFlags ) 2467 ) { 2468 /* no problem */ 2469 } 2470 else { 2471 ++errorCount; 2472 writeErrorFound( 10000 - count ); 2473 writeInput_a_float128(); 2474 fputs( "\n\t", stdout ); 2475 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags ); 2476 fflush( stdout ); 2477 if ( errorCount == maxErrorCount ) goto exit; 2478 } 2479 } 2480 } 2481 exit: 2482 writeTestsPerformed( 10000 - count ); 2483 2484} 2485 2486#ifdef FLOATX80 2487 2488void 2489 test_a_float128_z_floatx80( 2490 floatx80 trueFunction( float128 ), floatx80 testFunction( float128 ) ) 2491{ 2492 int16 count; 2493 floatx80 trueZ, testZ; 2494 uint8 trueFlags, testFlags; 2495 2496 errorCount = 0; 2497 tenthousandsCount = 0; 2498 count = 10000; 2499 testCases_initSequence( testCases_sequence_a_float128 ); 2500 writeTestsTotal(); 2501 while ( ! testCases_done || forever ) { 2502 testCases_next(); 2503 *trueFlagsPtr = 0; 2504 trueZ = trueFunction( testCases_a_float128 ); 2505 trueFlags = *trueFlagsPtr; 2506 (void) testFlagsFunctionPtr(); 2507 testZ = testFunction( testCases_a_float128 ); 2508 testFlags = testFlagsFunctionPtr(); 2509 --count; 2510 if ( count == 0 ) { 2511 checkEarlyExit(); 2512 count = 10000; 2513 } 2514 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 2515 if ( ! checkNaNs 2516 && float128_is_signaling_nan( testCases_a_float128 ) ) { 2517 trueFlags |= float_flag_invalid; 2518 } 2519 if ( ! checkNaNs 2520 && floatx80_isNaN( trueZ ) 2521 && floatx80_isNaN( testZ ) 2522 && ! floatx80_is_signaling_nan( testZ ) 2523 && ( trueFlags == testFlags ) 2524 ) { 2525 /* no problem */ 2526 } 2527 else { 2528 ++errorCount; 2529 writeErrorFound( 10000 - count ); 2530 writeInput_a_float128(); 2531 fputs( "\n\t", stdout ); 2532 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags ); 2533 fflush( stdout ); 2534 if ( errorCount == maxErrorCount ) goto exit; 2535 } 2536 } 2537 } 2538 exit: 2539 writeTestsPerformed( 10000 - count ); 2540 2541} 2542 2543#endif 2544 2545void 2546 test_az_float128( 2547 float128 trueFunction( float128 ), float128 testFunction( float128 ) ) 2548{ 2549 int16 count; 2550 float128 trueZ, testZ; 2551 uint8 trueFlags, testFlags; 2552 2553 errorCount = 0; 2554 tenthousandsCount = 0; 2555 count = 10000; 2556 testCases_initSequence( testCases_sequence_a_float128 ); 2557 writeTestsTotal(); 2558 while ( ! testCases_done || forever ) { 2559 testCases_next(); 2560 *trueFlagsPtr = 0; 2561 trueZ = trueFunction( testCases_a_float128 ); 2562 trueFlags = *trueFlagsPtr; 2563 (void) testFlagsFunctionPtr(); 2564 testZ = testFunction( testCases_a_float128 ); 2565 testFlags = testFlagsFunctionPtr(); 2566 --count; 2567 if ( count == 0 ) { 2568 checkEarlyExit(); 2569 count = 10000; 2570 } 2571 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 2572 if ( ! checkNaNs 2573 && float128_is_signaling_nan( testCases_a_float128 ) ) { 2574 trueFlags |= float_flag_invalid; 2575 } 2576 if ( ! checkNaNs 2577 && float128_isNaN( trueZ ) 2578 && float128_isNaN( testZ ) 2579 && ! float128_is_signaling_nan( testZ ) 2580 && ( trueFlags == testFlags ) 2581 ) { 2582 /* no problem */ 2583 } 2584 else { 2585 ++errorCount; 2586 writeErrorFound( 10000 - count ); 2587 writeInput_a_float128(); 2588 fputs( "\n\t", stdout ); 2589 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags ); 2590 fflush( stdout ); 2591 if ( errorCount == maxErrorCount ) goto exit; 2592 } 2593 } 2594 } 2595 exit: 2596 writeTestsPerformed( 10000 - count ); 2597 2598} 2599 2600void 2601 test_ab_float128_z_flag( 2602 flag trueFunction( float128, float128 ), 2603 flag testFunction( float128, float128 ) 2604 ) 2605{ 2606 int16 count; 2607 flag trueZ, testZ; 2608 uint8 trueFlags, testFlags; 2609 2610 errorCount = 0; 2611 tenthousandsCount = 0; 2612 count = 10000; 2613 testCases_initSequence( testCases_sequence_ab_float128 ); 2614 writeTestsTotal(); 2615 while ( ! testCases_done || forever ) { 2616 testCases_next(); 2617 *trueFlagsPtr = 0; 2618 trueZ = trueFunction( testCases_a_float128, testCases_b_float128 ); 2619 trueFlags = *trueFlagsPtr; 2620 (void) testFlagsFunctionPtr(); 2621 testZ = testFunction( testCases_a_float128, testCases_b_float128 ); 2622 testFlags = testFlagsFunctionPtr(); 2623 --count; 2624 if ( count == 0 ) { 2625 checkEarlyExit(); 2626 count = 10000; 2627 } 2628 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 2629 if ( ! checkNaNs 2630 && ( float128_is_signaling_nan( testCases_a_float128 ) 2631 || float128_is_signaling_nan( testCases_b_float128 ) ) 2632 ) { 2633 trueFlags |= float_flag_invalid; 2634 } 2635 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) { 2636 ++errorCount; 2637 writeErrorFound( 10000 - count ); 2638 writeInputs_ab_float128(); 2639 fputs( "\n\t", stdout ); 2640 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags ); 2641 fflush( stdout ); 2642 if ( errorCount == maxErrorCount ) goto exit; 2643 } 2644 } 2645 } 2646 exit: 2647 writeTestsPerformed( 10000 - count ); 2648 return; 2649 2650} 2651 2652void 2653 test_abz_float128( 2654 float128 trueFunction( float128, float128 ), 2655 float128 testFunction( float128, float128 ) 2656 ) 2657{ 2658 int16 count; 2659 float128 trueZ, testZ; 2660 uint8 trueFlags, testFlags; 2661 2662 errorCount = 0; 2663 tenthousandsCount = 0; 2664 count = 10000; 2665 testCases_initSequence( testCases_sequence_ab_float128 ); 2666 writeTestsTotal(); 2667 while ( ! testCases_done || forever ) { 2668 testCases_next(); 2669 *trueFlagsPtr = 0; 2670 trueZ = trueFunction( testCases_a_float128, testCases_b_float128 ); 2671 trueFlags = *trueFlagsPtr; 2672 (void) testFlagsFunctionPtr(); 2673 testZ = testFunction( testCases_a_float128, testCases_b_float128 ); 2674 testFlags = testFlagsFunctionPtr(); 2675 --count; 2676 if ( count == 0 ) { 2677 checkEarlyExit(); 2678 count = 10000; 2679 } 2680 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) { 2681 if ( ! checkNaNs 2682 && ( float128_is_signaling_nan( testCases_a_float128 ) 2683 || float128_is_signaling_nan( testCases_b_float128 ) ) 2684 ) { 2685 trueFlags |= float_flag_invalid; 2686 } 2687 if ( ! checkNaNs 2688 && float128_isNaN( trueZ ) 2689 && float128_isNaN( testZ ) 2690 && ! float128_is_signaling_nan( testZ ) 2691 && ( trueFlags == testFlags ) 2692 ) { 2693 /* no problem */ 2694 } 2695 else { 2696 ++errorCount; 2697 writeErrorFound( 10000 - count ); 2698 writeInputs_ab_float128(); 2699 fputs( "\n\t", stdout ); 2700 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags ); 2701 fflush( stdout ); 2702 if ( errorCount == maxErrorCount ) goto exit; 2703 } 2704 } 2705 } 2706 exit: 2707 writeTestsPerformed( 10000 - count ); 2708 return; 2709 2710} 2711 2712#endif 2713 2714