Sync usage with man page.
[netbsd-mini2440.git] / regress / lib / libc / ieeefp / testfloat / testLoops.c
blobdc3cfb3abcbace7f036996976d860919a1346690
1 /* $NetBSD: testLoops.c,v 1.4 2002/02/21 07:38:16 itojun Exp $ */
3 /* This is a derivative work. */
5 /*-
6 * Copyright (c) 2001 The NetBSD Foundation, Inc.
7 * All rights reserved.
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Ross Harvey.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
35 ===============================================================================
37 This C source file is part of TestFloat, Release 2a, a package of programs
38 for testing the correctness of floating-point arithmetic complying to the
39 IEC/IEEE Standard for Floating-Point.
41 Written by John R. Hauser. More information is available through the Web
42 page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
44 THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
45 has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
46 TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
47 PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
48 AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
50 Derivative works are acceptable, even for commercial purposes, so long as
51 (1) they include prominent notice that the work is derivative, and (2) they
52 include prominent notice akin to these four paragraphs for those parts of
53 this code that are retained.
55 ===============================================================================
58 #include <stdlib.h>
59 #include <stdio.h>
60 #include "milieu.h"
61 #include "softfloat.h"
62 #include "testCases.h"
63 #include "writeHex.h"
64 #include "testLoops.h"
66 volatile flag stop = FALSE;
68 const char *trueName, *testName;
69 flag forever, errorStop;
70 uint32 maxErrorCount = 0;
71 flag checkNaNs = FALSE;
72 int8 *trueFlagsPtr;
73 int8 ( *testFlagsFunctionPtr )( void );
74 const char *functionName;
75 const char *roundingPrecisionName, *roundingModeName, *tininessModeName;
76 flag anyErrors = FALSE;
78 void writeFunctionName( FILE *stream )
81 fputs( functionName, stream );
82 if ( roundingModeName ) {
83 if ( roundingPrecisionName ) {
84 fputs( ", precision ", stream );
85 fputs( roundingPrecisionName, stream );
87 fputs( ", rounding ", stream );
88 fputs( roundingModeName, stream );
89 if ( tininessModeName ) {
90 fputs( ", tininess ", stream );
91 fputs( tininessModeName, stream );
92 fputs( " rounding", stream );
98 void exitWithStatus( void )
101 exit( anyErrors ? EXIT_FAILURE : EXIT_SUCCESS );
105 static uint32 tenthousandsCount, errorCount = 0;
107 static void writeTestsTotal( void )
110 if ( forever ) {
111 fputs( "Unbounded tests.\n", stderr );
113 else {
114 fprintf( stderr, "%d tests total.\n", testCases_total );
119 static void writeTestsPerformed( int16 count )
122 if ( tenthousandsCount ) {
123 fprintf(
124 stderr, "%d%04d tests performed", tenthousandsCount, count );
126 else {
127 fprintf( stderr, "%d tests performed", count );
129 if ( errorCount ) {
130 fprintf(
131 stderr,
132 "; %d error%s found.\n",
133 errorCount,
134 ( errorCount == 1 ) ? "" : "s"
137 else {
138 fputs( ".\n", stderr );
139 fputs( "No errors found in ", stdout );
140 writeFunctionName( stdout );
141 fputs( ".\n", stdout );
142 fflush( stdout );
147 static void checkEarlyExit( void )
150 ++tenthousandsCount;
151 if ( stop ) {
152 writeTestsPerformed( 0 );
153 exitWithStatus();
155 fprintf( stderr, "%3d0000", tenthousandsCount );
159 static void writeErrorFound( int16 count )
162 if ( errorCount == 1 ) {
163 fputs( "Errors found in ", stdout );
164 writeFunctionName( stdout );
165 fputs( ":\n", stdout );
167 if ( stop ) {
168 writeTestsPerformed( count );
169 exitWithStatus();
171 anyErrors = TRUE;
175 INLINE void writeInput_a_int32( void )
178 writeHex_bits32( testCases_a_int32, stdout );
182 #ifdef BITS64
184 INLINE void writeInput_a_int64( void )
187 writeHex_bits64( testCases_a_int64, stdout );
191 #endif
193 INLINE void writeInput_a_float32( void )
196 writeHex_float32( testCases_a_float32, stdout );
200 static void writeInputs_ab_float32( void )
203 writeHex_float32( testCases_a_float32, stdout );
204 fputs( " ", stdout );
205 writeHex_float32( testCases_b_float32, stdout );
209 INLINE void writeInput_a_float64( void )
212 writeHex_float64( testCases_a_float64, stdout );
216 static void writeInputs_ab_float64( void )
219 writeHex_float64( testCases_a_float64, stdout );
220 fputs( " ", stdout );
221 writeHex_float64( testCases_b_float64, stdout );
225 #ifdef FLOATX80
227 INLINE void writeInput_a_floatx80( void )
230 writeHex_floatx80( testCases_a_floatx80, stdout );
234 static void writeInputs_ab_floatx80( void )
237 writeHex_floatx80( testCases_a_floatx80, stdout );
238 fputs( " ", stdout );
239 writeHex_floatx80( testCases_b_floatx80, stdout );
243 #endif
245 #ifdef FLOAT128
247 INLINE void writeInput_a_float128( void )
250 writeHex_float128( testCases_a_float128, stdout );
254 static void writeInputs_ab_float128( void )
257 writeHex_float128( testCases_a_float128, stdout );
258 fputs( " ", stdout );
259 writeHex_float128( testCases_b_float128, stdout );
263 #endif
265 static void
266 writeOutputs_z_flag(
267 flag trueZ, uint8 trueFlags, flag testZ, uint8 testFlags )
270 fputs( trueName, stdout );
271 fputs( ": ", stdout );
272 writeHex_flag( trueZ, stdout );
273 fputc( ' ', stdout );
274 writeHex_float_flags( trueFlags, stdout );
275 fputs( " ", stdout );
276 fputs( testName, stdout );
277 fputs( ": ", stdout );
278 writeHex_flag( testZ, stdout );
279 fputc( ' ', stdout );
280 writeHex_float_flags( testFlags, stdout );
281 fputc( '\n', stdout );
285 static void
286 writeOutputs_z_int32(
287 int32 trueZ, uint8 trueFlags, int32 testZ, uint8 testFlags )
290 fputs( trueName, stdout );
291 fputs( ": ", stdout );
292 writeHex_bits32( trueZ, stdout );
293 fputc( ' ', stdout );
294 writeHex_float_flags( trueFlags, stdout );
295 fputs( " ", stdout );
296 fputs( testName, stdout );
297 fputs( ": ", stdout );
298 writeHex_bits32( testZ, stdout );
299 fputc( ' ', stdout );
300 writeHex_float_flags( testFlags, stdout );
301 fputc( '\n', stdout );
305 #ifdef BITS64
307 static void
308 writeOutputs_z_int64(
309 int64 trueZ, uint8 trueFlags, int64 testZ, uint8 testFlags )
312 fputs( trueName, stdout );
313 fputs( ": ", stdout );
314 writeHex_bits64( trueZ, stdout );
315 fputc( ' ', stdout );
316 writeHex_float_flags( trueFlags, stdout );
317 fputs( " ", stdout );
318 fputs( testName, stdout );
319 fputs( ": ", stdout );
320 writeHex_bits64( testZ, stdout );
321 fputc( ' ', stdout );
322 writeHex_float_flags( testFlags, stdout );
323 fputc( '\n', stdout );
327 #endif
329 static void
330 writeOutputs_z_float32(
331 float32 trueZ, uint8 trueFlags, float32 testZ, uint8 testFlags )
334 fputs( trueName, stdout );
335 fputs( ": ", stdout );
336 writeHex_float32( trueZ, stdout );
337 fputc( ' ', stdout );
338 writeHex_float_flags( trueFlags, stdout );
339 fputs( " ", stdout );
340 fputs( testName, stdout );
341 fputs( ": ", stdout );
342 writeHex_float32( testZ, stdout );
343 fputc( ' ', stdout );
344 writeHex_float_flags( testFlags, stdout );
345 fputc( '\n', stdout );
349 static void
350 writeOutputs_z_float64(
351 float64 trueZ, uint8 trueFlags, float64 testZ, uint8 testFlags )
354 fputs( trueName, stdout );
355 fputs( ": ", stdout );
356 writeHex_float64( trueZ, stdout );
357 fputc( ' ', stdout );
358 writeHex_float_flags( trueFlags, stdout );
359 fputs( " ", stdout );
360 fputs( testName, stdout );
361 fputs( ": ", stdout );
362 writeHex_float64( testZ, stdout );
363 fputc( ' ', stdout );
364 writeHex_float_flags( testFlags, stdout );
365 fputc( '\n', stdout );
369 #ifdef FLOATX80
371 static void
372 writeOutputs_z_floatx80(
373 floatx80 trueZ, uint8 trueFlags, floatx80 testZ, uint8 testFlags )
376 fputs( trueName, stdout );
377 fputs( ": ", stdout );
378 writeHex_floatx80( trueZ, stdout );
379 fputc( ' ', stdout );
380 writeHex_float_flags( trueFlags, stdout );
381 fputs( " ", stdout );
382 fputs( testName, stdout );
383 fputs( ": ", stdout );
384 writeHex_floatx80( testZ, stdout );
385 fputc( ' ', stdout );
386 writeHex_float_flags( testFlags, stdout );
387 fputc( '\n', stdout );
391 #endif
393 #ifdef FLOAT128
395 static void
396 writeOutputs_z_float128(
397 float128 trueZ, uint8 trueFlags, float128 testZ, uint8 testFlags )
400 fputs( trueName, stdout );
401 fputs( ": ", stdout );
402 writeHex_float128( trueZ, stdout );
403 fputc( ' ', stdout );
404 writeHex_float_flags( trueFlags, stdout );
405 fputs( "\n\t", stdout );
406 fputs( testName, stdout );
407 fputs( ": ", stdout );
408 writeHex_float128( testZ, stdout );
409 fputc( ' ', stdout );
410 writeHex_float_flags( testFlags, stdout );
411 fputc( '\n', stdout );
415 #endif
417 INLINE flag float32_isNaN( float32 a )
420 return 0x7F800000 < ( a & 0x7FFFFFFF );
424 #ifdef BITS64
426 INLINE flag float64_same( float64 a, float64 b )
429 return a == b;
433 INLINE flag float64_isNaN( float64 a )
436 return LIT64( 0x7FF0000000000000 ) < ( a & LIT64( 0x7FFFFFFFFFFFFFFF ) );
440 #else
442 INLINE flag float64_same( float64 a, float64 b )
445 return ( a.high == b.high ) && ( a.low == b.low );
449 INLINE flag float64_isNaN( float64 a )
451 bits32 absAHigh;
453 absAHigh = a.high & 0x7FFFFFFF;
454 return
455 ( 0x7FF00000 < absAHigh ) || ( ( absAHigh == 0x7FF00000 ) && a.low );
459 #endif
461 #ifdef FLOATX80
463 INLINE flag floatx80_same( floatx80 a, floatx80 b )
466 return ( a.high == b.high ) && ( a.low == b.low );
470 INLINE flag floatx80_isNaN( floatx80 a )
473 return ( ( a.high & 0x7FFF ) == 0x7FFF ) && a.low;
477 #endif
479 #ifdef FLOAT128
481 INLINE flag float128_same( float128 a, float128 b )
484 return ( a.high == b.high ) && ( a.low == b.low );
488 INLINE flag float128_isNaN( float128 a )
490 bits64 absAHigh;
492 absAHigh = a.high & LIT64( 0x7FFFFFFFFFFFFFFF );
493 return
494 ( LIT64( 0x7FFF000000000000 ) < absAHigh )
495 || ( ( absAHigh == LIT64( 0x7FFF000000000000 ) ) && a.low );
499 #endif
501 void
502 test_a_int32_z_float32(
503 float32 trueFunction( int32 ), float32 testFunction( int32 ) )
505 int16 count;
506 float32 trueZ, testZ;
507 uint8 trueFlags, testFlags;
509 errorCount = 0;
510 tenthousandsCount = 0;
511 count = 10000;
512 testCases_initSequence( testCases_sequence_a_int32 );
513 writeTestsTotal();
514 while ( ! testCases_done || forever ) {
515 testCases_next();
516 *trueFlagsPtr = 0;
517 trueZ = trueFunction( testCases_a_int32 );
518 trueFlags = *trueFlagsPtr;
519 (void) testFlagsFunctionPtr();
520 testZ = testFunction( testCases_a_int32 );
521 testFlags = testFlagsFunctionPtr();
522 --count;
523 if ( count == 0 ) {
524 checkEarlyExit();
525 count = 10000;
527 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
528 if ( ! checkNaNs
529 && float32_isNaN( trueZ )
530 && float32_isNaN( testZ )
531 && ! float32_is_signaling_nan( testZ )
532 && ( trueFlags == testFlags )
534 /* no problem */
536 else {
537 ++errorCount;
538 writeErrorFound( 10000 - count );
539 writeInput_a_int32();
540 fputs( " ", stdout );
541 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
542 fflush( stdout );
543 if ( errorCount == maxErrorCount ) goto exit;
547 exit:
548 writeTestsPerformed( 10000 - count );
552 void
553 test_a_int32_z_float64(
554 float64 trueFunction( int32 ), float64 testFunction( int32 ) )
556 int16 count;
557 float64 trueZ, testZ;
558 uint8 trueFlags, testFlags;
560 errorCount = 0;
561 tenthousandsCount = 0;
562 count = 10000;
563 testCases_initSequence( testCases_sequence_a_int32 );
564 writeTestsTotal();
565 while ( ! testCases_done || forever ) {
566 testCases_next();
567 *trueFlagsPtr = 0;
568 trueZ = trueFunction( testCases_a_int32 );
569 trueFlags = *trueFlagsPtr;
570 (void) testFlagsFunctionPtr();
571 testZ = testFunction( testCases_a_int32 );
572 testFlags = testFlagsFunctionPtr();
573 --count;
574 if ( count == 0 ) {
575 checkEarlyExit();
576 count = 10000;
578 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
579 if ( ! checkNaNs
580 && float64_isNaN( trueZ )
581 && float64_isNaN( testZ )
582 && ! float64_is_signaling_nan( testZ )
583 && ( trueFlags == testFlags )
585 /* no problem */
587 else {
588 ++errorCount;
589 writeErrorFound( 10000 - count );
590 writeInput_a_int32();
591 fputs( " ", stdout );
592 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
593 fflush( stdout );
594 if ( errorCount == maxErrorCount ) goto exit;
598 exit:
599 writeTestsPerformed( 10000 - count );
603 #ifdef FLOATX80
605 void
606 test_a_int32_z_floatx80(
607 floatx80 trueFunction( int32 ), floatx80 testFunction( int32 ) )
609 int16 count;
610 floatx80 trueZ, testZ;
611 uint8 trueFlags, testFlags;
613 errorCount = 0;
614 tenthousandsCount = 0;
615 count = 10000;
616 testCases_initSequence( testCases_sequence_a_int32 );
617 writeTestsTotal();
618 while ( ! testCases_done || forever ) {
619 testCases_next();
620 *trueFlagsPtr = 0;
621 trueZ = trueFunction( testCases_a_int32 );
622 trueFlags = *trueFlagsPtr;
623 (void) testFlagsFunctionPtr();
624 testZ = testFunction( testCases_a_int32 );
625 testFlags = testFlagsFunctionPtr();
626 --count;
627 if ( count == 0 ) {
628 checkEarlyExit();
629 count = 10000;
631 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
632 if ( ! checkNaNs
633 && floatx80_isNaN( trueZ )
634 && floatx80_isNaN( testZ )
635 && ! floatx80_is_signaling_nan( testZ )
636 && ( trueFlags == testFlags )
638 /* no problem */
640 else {
641 ++errorCount;
642 writeErrorFound( 10000 - count );
643 writeInput_a_int32();
644 fputs( " ", stdout );
645 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
646 fflush( stdout );
647 if ( errorCount == maxErrorCount ) goto exit;
651 exit:
652 writeTestsPerformed( 10000 - count );
656 #endif
658 #ifdef FLOAT128
660 void
661 test_a_int32_z_float128(
662 float128 trueFunction( int32 ), float128 testFunction( int32 ) )
664 int16 count;
665 float128 trueZ, testZ;
666 uint8 trueFlags, testFlags;
668 errorCount = 0;
669 tenthousandsCount = 0;
670 count = 10000;
671 testCases_initSequence( testCases_sequence_a_int32 );
672 writeTestsTotal();
673 while ( ! testCases_done || forever ) {
674 testCases_next();
675 *trueFlagsPtr = 0;
676 trueZ = trueFunction( testCases_a_int32 );
677 trueFlags = *trueFlagsPtr;
678 (void) testFlagsFunctionPtr();
679 testZ = testFunction( testCases_a_int32 );
680 testFlags = testFlagsFunctionPtr();
681 --count;
682 if ( count == 0 ) {
683 checkEarlyExit();
684 count = 10000;
686 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
687 if ( ! checkNaNs
688 && float128_isNaN( trueZ )
689 && float128_isNaN( testZ )
690 && ! float128_is_signaling_nan( testZ )
691 && ( trueFlags == testFlags )
693 /* no problem */
695 else {
696 ++errorCount;
697 writeErrorFound( 10000 - count );
698 writeInput_a_int32();
699 fputs( "\n\t", stdout );
700 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
701 fflush( stdout );
702 if ( errorCount == maxErrorCount ) goto exit;
706 exit:
707 writeTestsPerformed( 10000 - count );
711 #endif
713 #ifdef BITS64
715 void
716 test_a_int64_z_float32(
717 float32 trueFunction( int64 ), float32 testFunction( int64 ) )
719 int16 count;
720 float32 trueZ, testZ;
721 uint8 trueFlags, testFlags;
723 errorCount = 0;
724 tenthousandsCount = 0;
725 count = 10000;
726 testCases_initSequence( testCases_sequence_a_int64 );
727 writeTestsTotal();
728 while ( ! testCases_done || forever ) {
729 testCases_next();
730 *trueFlagsPtr = 0;
731 trueZ = trueFunction( testCases_a_int64 );
732 trueFlags = *trueFlagsPtr;
733 (void) testFlagsFunctionPtr();
734 testZ = testFunction( testCases_a_int64 );
735 testFlags = testFlagsFunctionPtr();
736 --count;
737 if ( count == 0 ) {
738 checkEarlyExit();
739 count = 10000;
741 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
742 if ( ! checkNaNs
743 && float32_isNaN( trueZ )
744 && float32_isNaN( testZ )
745 && ! float32_is_signaling_nan( testZ )
746 && ( trueFlags == testFlags )
748 /* no problem */
750 else {
751 ++errorCount;
752 writeErrorFound( 10000 - count );
753 writeInput_a_int64();
754 fputs( " ", stdout );
755 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
756 fflush( stdout );
757 if ( errorCount == maxErrorCount ) goto exit;
761 exit:
762 writeTestsPerformed( 10000 - count );
766 void
767 test_a_int64_z_float64(
768 float64 trueFunction( int64 ), float64 testFunction( int64 ) )
770 int16 count;
771 float64 trueZ, testZ;
772 uint8 trueFlags, testFlags;
774 errorCount = 0;
775 tenthousandsCount = 0;
776 count = 10000;
777 testCases_initSequence( testCases_sequence_a_int64 );
778 writeTestsTotal();
779 while ( ! testCases_done || forever ) {
780 testCases_next();
781 *trueFlagsPtr = 0;
782 trueZ = trueFunction( testCases_a_int64 );
783 trueFlags = *trueFlagsPtr;
784 (void) testFlagsFunctionPtr();
785 testZ = testFunction( testCases_a_int64 );
786 testFlags = testFlagsFunctionPtr();
787 --count;
788 if ( count == 0 ) {
789 checkEarlyExit();
790 count = 10000;
792 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
793 if ( ! checkNaNs
794 && float64_isNaN( trueZ )
795 && float64_isNaN( testZ )
796 && ! float64_is_signaling_nan( testZ )
797 && ( trueFlags == testFlags )
799 /* no problem */
801 else {
802 ++errorCount;
803 writeErrorFound( 10000 - count );
804 writeInput_a_int64();
805 fputs( " ", stdout );
806 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
807 fflush( stdout );
808 if ( errorCount == maxErrorCount ) goto exit;
812 exit:
813 writeTestsPerformed( 10000 - count );
817 #ifdef FLOATX80
819 void
820 test_a_int64_z_floatx80(
821 floatx80 trueFunction( int64 ), floatx80 testFunction( int64 ) )
823 int16 count;
824 floatx80 trueZ, testZ;
825 uint8 trueFlags, testFlags;
827 errorCount = 0;
828 tenthousandsCount = 0;
829 count = 10000;
830 testCases_initSequence( testCases_sequence_a_int64 );
831 writeTestsTotal();
832 while ( ! testCases_done || forever ) {
833 testCases_next();
834 *trueFlagsPtr = 0;
835 trueZ = trueFunction( testCases_a_int64 );
836 trueFlags = *trueFlagsPtr;
837 (void) testFlagsFunctionPtr();
838 testZ = testFunction( testCases_a_int64 );
839 testFlags = testFlagsFunctionPtr();
840 --count;
841 if ( count == 0 ) {
842 checkEarlyExit();
843 count = 10000;
845 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
846 if ( ! checkNaNs
847 && floatx80_isNaN( trueZ )
848 && floatx80_isNaN( testZ )
849 && ! floatx80_is_signaling_nan( testZ )
850 && ( trueFlags == testFlags )
852 /* no problem */
854 else {
855 ++errorCount;
856 writeErrorFound( 10000 - count );
857 writeInput_a_int64();
858 fputs( " ", stdout );
859 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
860 fflush( stdout );
861 if ( errorCount == maxErrorCount ) goto exit;
865 exit:
866 writeTestsPerformed( 10000 - count );
870 #endif
872 #ifdef FLOAT128
874 void
875 test_a_int64_z_float128(
876 float128 trueFunction( int64 ), float128 testFunction( int64 ) )
878 int16 count;
879 float128 trueZ, testZ;
880 uint8 trueFlags, testFlags;
882 errorCount = 0;
883 tenthousandsCount = 0;
884 count = 10000;
885 testCases_initSequence( testCases_sequence_a_int64 );
886 writeTestsTotal();
887 while ( ! testCases_done || forever ) {
888 testCases_next();
889 *trueFlagsPtr = 0;
890 trueZ = trueFunction( testCases_a_int64 );
891 trueFlags = *trueFlagsPtr;
892 (void) testFlagsFunctionPtr();
893 testZ = testFunction( testCases_a_int64 );
894 testFlags = testFlagsFunctionPtr();
895 --count;
896 if ( count == 0 ) {
897 checkEarlyExit();
898 count = 10000;
900 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
901 if ( ! checkNaNs
902 && float128_isNaN( trueZ )
903 && float128_isNaN( testZ )
904 && ! float128_is_signaling_nan( testZ )
905 && ( trueFlags == testFlags )
907 /* no problem */
909 else {
910 ++errorCount;
911 writeErrorFound( 10000 - count );
912 writeInput_a_int64();
913 fputs( "\n\t", stdout );
914 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
915 fflush( stdout );
916 if ( errorCount == maxErrorCount ) goto exit;
920 exit:
921 writeTestsPerformed( 10000 - count );
925 #endif
927 #endif
929 void
930 test_a_float32_z_int32(
931 int32 trueFunction( float32 ), int32 testFunction( float32 ) )
933 int16 count;
934 int32 trueZ, testZ;
935 uint8 trueFlags, testFlags;
937 errorCount = 0;
938 tenthousandsCount = 0;
939 count = 10000;
940 testCases_initSequence( testCases_sequence_a_float32 );
941 writeTestsTotal();
942 while ( ! testCases_done || forever ) {
943 testCases_next();
944 *trueFlagsPtr = 0;
945 trueZ = trueFunction( testCases_a_float32 );
946 trueFlags = *trueFlagsPtr;
947 (void) testFlagsFunctionPtr();
948 testZ = testFunction( testCases_a_float32 );
949 testFlags = testFlagsFunctionPtr();
950 --count;
951 if ( count == 0 ) {
952 checkEarlyExit();
953 count = 10000;
955 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
956 if ( ! checkNaNs
957 && float32_is_signaling_nan( testCases_a_float32 ) ) {
958 trueFlags |= float_flag_invalid;
960 if ( ( trueZ == 0x7FFFFFFF )
961 && ( ( testZ == 0x7FFFFFFF )
962 || ( testZ == (sbits32) 0x80000000 ) )
963 && ( trueFlags == float_flag_invalid )
964 && ( testFlags == float_flag_invalid )
966 /* no problem */
968 else {
969 ++errorCount;
970 writeErrorFound( 10000 - count );
971 writeInput_a_float32();
972 fputs( " ", stdout );
973 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags );
974 fflush( stdout );
975 if ( errorCount == maxErrorCount ) goto exit;
979 exit:
980 writeTestsPerformed( 10000 - count );
984 #ifdef BITS64
986 void
987 test_a_float32_z_int64(
988 int64 trueFunction( float32 ), int64 testFunction( float32 ) )
990 int16 count;
991 int64 trueZ, testZ;
992 uint8 trueFlags, testFlags;
994 errorCount = 0;
995 tenthousandsCount = 0;
996 count = 10000;
997 testCases_initSequence( testCases_sequence_a_float32 );
998 writeTestsTotal();
999 while ( ! testCases_done || forever ) {
1000 testCases_next();
1001 *trueFlagsPtr = 0;
1002 trueZ = trueFunction( testCases_a_float32 );
1003 trueFlags = *trueFlagsPtr;
1004 (void) testFlagsFunctionPtr();
1005 testZ = testFunction( testCases_a_float32 );
1006 testFlags = testFlagsFunctionPtr();
1007 --count;
1008 if ( count == 0 ) {
1009 checkEarlyExit();
1010 count = 10000;
1012 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1013 if ( ! checkNaNs
1014 && float32_is_signaling_nan( testCases_a_float32 ) ) {
1015 trueFlags |= float_flag_invalid;
1017 if ( ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1018 && ( ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1019 || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) )
1020 && ( trueFlags == float_flag_invalid )
1021 && ( testFlags == float_flag_invalid )
1023 /* no problem */
1025 else {
1026 ++errorCount;
1027 writeErrorFound( 10000 - count );
1028 writeInput_a_float32();
1029 fputs( " ", stdout );
1030 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags );
1031 fflush( stdout );
1032 if ( errorCount == maxErrorCount ) goto exit;
1036 exit:
1037 writeTestsPerformed( 10000 - count );
1041 #endif
1043 void
1044 test_a_float32_z_float64(
1045 float64 trueFunction( float32 ), float64 testFunction( float32 ) )
1047 int16 count;
1048 float64 trueZ, testZ;
1049 uint8 trueFlags, testFlags;
1051 errorCount = 0;
1052 tenthousandsCount = 0;
1053 count = 10000;
1054 testCases_initSequence( testCases_sequence_a_float32 );
1055 writeTestsTotal();
1056 while ( ! testCases_done || forever ) {
1057 testCases_next();
1058 *trueFlagsPtr = 0;
1059 trueZ = trueFunction( testCases_a_float32 );
1060 trueFlags = *trueFlagsPtr;
1061 (void) testFlagsFunctionPtr();
1062 testZ = testFunction( testCases_a_float32 );
1063 testFlags = testFlagsFunctionPtr();
1064 --count;
1065 if ( count == 0 ) {
1066 checkEarlyExit();
1067 count = 10000;
1069 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1070 if ( ! checkNaNs
1071 && float32_is_signaling_nan( testCases_a_float32 ) ) {
1072 trueFlags |= float_flag_invalid;
1074 if ( ! checkNaNs
1075 && float64_isNaN( trueZ )
1076 && float64_isNaN( testZ )
1077 && ! float64_is_signaling_nan( testZ )
1078 && ( trueFlags == testFlags )
1080 /* no problem */
1082 else {
1083 ++errorCount;
1084 writeErrorFound( 10000 - count );
1085 writeInput_a_float32();
1086 fputs( " ", stdout );
1087 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
1088 fflush( stdout );
1089 if ( errorCount == maxErrorCount ) goto exit;
1093 exit:
1094 writeTestsPerformed( 10000 - count );
1098 #ifdef FLOATX80
1100 void
1101 test_a_float32_z_floatx80(
1102 floatx80 trueFunction( float32 ), floatx80 testFunction( float32 ) )
1104 int16 count;
1105 floatx80 trueZ, testZ;
1106 uint8 trueFlags, testFlags;
1108 errorCount = 0;
1109 tenthousandsCount = 0;
1110 count = 10000;
1111 testCases_initSequence( testCases_sequence_a_float32 );
1112 writeTestsTotal();
1113 while ( ! testCases_done || forever ) {
1114 testCases_next();
1115 *trueFlagsPtr = 0;
1116 trueZ = trueFunction( testCases_a_float32 );
1117 trueFlags = *trueFlagsPtr;
1118 (void) testFlagsFunctionPtr();
1119 testZ = testFunction( testCases_a_float32 );
1120 testFlags = testFlagsFunctionPtr();
1121 --count;
1122 if ( count == 0 ) {
1123 checkEarlyExit();
1124 count = 10000;
1126 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1127 if ( ! checkNaNs
1128 && float32_is_signaling_nan( testCases_a_float32 ) ) {
1129 trueFlags |= float_flag_invalid;
1131 if ( ! checkNaNs
1132 && floatx80_isNaN( trueZ )
1133 && floatx80_isNaN( testZ )
1134 && ! floatx80_is_signaling_nan( testZ )
1135 && ( trueFlags == testFlags )
1137 /* no problem */
1139 else {
1140 ++errorCount;
1141 writeErrorFound( 10000 - count );
1142 writeInput_a_float32();
1143 fputs( "\n\t", stdout );
1144 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
1145 fflush( stdout );
1146 if ( errorCount == maxErrorCount ) goto exit;
1150 exit:
1151 writeTestsPerformed( 10000 - count );
1155 #endif
1157 #ifdef FLOAT128
1159 void
1160 test_a_float32_z_float128(
1161 float128 trueFunction( float32 ), float128 testFunction( float32 ) )
1163 int16 count;
1164 float128 trueZ, testZ;
1165 uint8 trueFlags, testFlags;
1167 errorCount = 0;
1168 tenthousandsCount = 0;
1169 count = 10000;
1170 testCases_initSequence( testCases_sequence_a_float32 );
1171 writeTestsTotal();
1172 while ( ! testCases_done || forever ) {
1173 testCases_next();
1174 *trueFlagsPtr = 0;
1175 trueZ = trueFunction( testCases_a_float32 );
1176 trueFlags = *trueFlagsPtr;
1177 (void) testFlagsFunctionPtr();
1178 testZ = testFunction( testCases_a_float32 );
1179 testFlags = testFlagsFunctionPtr();
1180 --count;
1181 if ( count == 0 ) {
1182 checkEarlyExit();
1183 count = 10000;
1185 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1186 if ( ! checkNaNs
1187 && float32_is_signaling_nan( testCases_a_float32 ) ) {
1188 trueFlags |= float_flag_invalid;
1190 if ( ! checkNaNs
1191 && float128_isNaN( trueZ )
1192 && float128_isNaN( testZ )
1193 && ! float128_is_signaling_nan( testZ )
1194 && ( trueFlags == testFlags )
1196 /* no problem */
1198 else {
1199 ++errorCount;
1200 writeErrorFound( 10000 - count );
1201 writeInput_a_float32();
1202 fputs( "\n\t", stdout );
1203 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
1204 fflush( stdout );
1205 if ( errorCount == maxErrorCount ) goto exit;
1209 exit:
1210 writeTestsPerformed( 10000 - count );
1214 #endif
1216 void
1217 test_az_float32(
1218 float32 trueFunction( float32 ), float32 testFunction( float32 ) )
1220 int16 count;
1221 float32 trueZ, testZ;
1222 uint8 trueFlags, testFlags;
1224 errorCount = 0;
1225 tenthousandsCount = 0;
1226 count = 10000;
1227 testCases_initSequence( testCases_sequence_a_float32 );
1228 writeTestsTotal();
1229 while ( ! testCases_done || forever ) {
1230 testCases_next();
1231 *trueFlagsPtr = 0;
1232 trueZ = trueFunction( testCases_a_float32 );
1233 trueFlags = *trueFlagsPtr;
1234 (void) testFlagsFunctionPtr();
1235 testZ = testFunction( testCases_a_float32 );
1236 testFlags = testFlagsFunctionPtr();
1237 --count;
1238 if ( count == 0 ) {
1239 checkEarlyExit();
1240 count = 10000;
1242 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1243 if ( ! checkNaNs
1244 && float32_is_signaling_nan( testCases_a_float32 ) ) {
1245 trueFlags |= float_flag_invalid;
1247 if ( ! checkNaNs
1248 && float32_isNaN( trueZ )
1249 && float32_isNaN( testZ )
1250 && ! float32_is_signaling_nan( testZ )
1251 && ( trueFlags == testFlags )
1253 /* no problem */
1255 else {
1256 ++errorCount;
1257 writeErrorFound( 10000 - count );
1258 writeInput_a_float32();
1259 fputs( " ", stdout );
1260 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
1261 fflush( stdout );
1262 if ( errorCount == maxErrorCount ) goto exit;
1266 exit:
1267 writeTestsPerformed( 10000 - count );
1271 void
1272 test_ab_float32_z_flag(
1273 flag trueFunction( float32, float32 ),
1274 flag testFunction( float32, float32 )
1277 int16 count;
1278 flag trueZ, testZ;
1279 uint8 trueFlags, testFlags;
1281 errorCount = 0;
1282 tenthousandsCount = 0;
1283 count = 10000;
1284 testCases_initSequence( testCases_sequence_ab_float32 );
1285 writeTestsTotal();
1286 while ( ! testCases_done || forever ) {
1287 testCases_next();
1288 *trueFlagsPtr = 0;
1289 trueZ = trueFunction( testCases_a_float32, testCases_b_float32 );
1290 trueFlags = *trueFlagsPtr;
1291 (void) testFlagsFunctionPtr();
1292 testZ = testFunction( testCases_a_float32, testCases_b_float32 );
1293 testFlags = testFlagsFunctionPtr();
1294 --count;
1295 if ( count == 0 ) {
1296 checkEarlyExit();
1297 count = 10000;
1299 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1300 if ( ! checkNaNs
1301 && ( float32_is_signaling_nan( testCases_a_float32 )
1302 || float32_is_signaling_nan( testCases_b_float32 ) )
1304 trueFlags |= float_flag_invalid;
1306 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1307 ++errorCount;
1308 writeErrorFound( 10000 - count );
1309 writeInputs_ab_float32();
1310 fputs( " ", stdout );
1311 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags );
1312 fflush( stdout );
1313 if ( errorCount == maxErrorCount ) goto exit;
1317 exit:
1318 writeTestsPerformed( 10000 - count );
1319 return;
1323 void
1324 test_abz_float32(
1325 float32 trueFunction( float32, float32 ),
1326 float32 testFunction( float32, float32 )
1329 int16 count;
1330 float32 trueZ, testZ;
1331 uint8 trueFlags, testFlags;
1333 errorCount = 0;
1334 tenthousandsCount = 0;
1335 count = 10000;
1336 testCases_initSequence( testCases_sequence_ab_float32 );
1337 writeTestsTotal();
1338 while ( ! testCases_done || forever ) {
1339 testCases_next();
1340 *trueFlagsPtr = 0;
1341 trueZ = trueFunction( testCases_a_float32, testCases_b_float32 );
1342 trueFlags = *trueFlagsPtr;
1343 (void) testFlagsFunctionPtr();
1344 testZ = testFunction( testCases_a_float32, testCases_b_float32 );
1345 testFlags = testFlagsFunctionPtr();
1346 --count;
1347 if ( count == 0 ) {
1348 checkEarlyExit();
1349 count = 10000;
1351 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1352 if ( ! checkNaNs
1353 && ( float32_is_signaling_nan( testCases_a_float32 )
1354 || float32_is_signaling_nan( testCases_b_float32 ) )
1356 trueFlags |= float_flag_invalid;
1358 if ( ! checkNaNs
1359 && float32_isNaN( trueZ )
1360 && float32_isNaN( testZ )
1361 && ! float32_is_signaling_nan( testZ )
1362 && ( trueFlags == testFlags )
1364 /* no problem */
1366 else {
1367 ++errorCount;
1368 writeErrorFound( 10000 - count );
1369 writeInputs_ab_float32();
1370 fputs( " ", stdout );
1371 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
1372 fflush( stdout );
1373 if ( errorCount == maxErrorCount ) goto exit;
1377 exit:
1378 writeTestsPerformed( 10000 - count );
1379 return;
1383 void
1384 test_a_float64_z_int32(
1385 int32 trueFunction( float64 ), int32 testFunction( float64 ) )
1387 int16 count;
1388 int32 trueZ, testZ;
1389 uint8 trueFlags, testFlags;
1391 errorCount = 0;
1392 tenthousandsCount = 0;
1393 count = 10000;
1394 testCases_initSequence( testCases_sequence_a_float64 );
1395 writeTestsTotal();
1396 while ( ! testCases_done || forever ) {
1397 testCases_next();
1398 *trueFlagsPtr = 0;
1399 trueZ = trueFunction( testCases_a_float64 );
1400 trueFlags = *trueFlagsPtr;
1401 (void) testFlagsFunctionPtr();
1402 testZ = testFunction( testCases_a_float64 );
1403 testFlags = testFlagsFunctionPtr();
1404 --count;
1405 if ( count == 0 ) {
1406 checkEarlyExit();
1407 count = 10000;
1409 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1410 if ( ! checkNaNs
1411 && float64_is_signaling_nan( testCases_a_float64 ) ) {
1412 trueFlags |= float_flag_invalid;
1414 if ( ( trueZ == 0x7FFFFFFF )
1415 && ( ( testZ == 0x7FFFFFFF )
1416 || ( testZ == (sbits32) 0x80000000 ) )
1417 && ( trueFlags == float_flag_invalid )
1418 && ( testFlags == float_flag_invalid )
1420 /* no problem */
1422 else {
1423 ++errorCount;
1424 writeErrorFound( 10000 - count );
1425 writeInput_a_float64();
1426 fputs( " ", stdout );
1427 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags );
1428 fflush( stdout );
1429 if ( errorCount == maxErrorCount ) goto exit;
1433 exit:
1434 writeTestsPerformed( 10000 - count );
1438 #ifdef BITS64
1440 void
1441 test_a_float64_z_int64(
1442 int64 trueFunction( float64 ), int64 testFunction( float64 ) )
1444 int16 count;
1445 int64 trueZ, testZ;
1446 uint8 trueFlags, testFlags;
1448 errorCount = 0;
1449 tenthousandsCount = 0;
1450 count = 10000;
1451 testCases_initSequence( testCases_sequence_a_float64 );
1452 writeTestsTotal();
1453 while ( ! testCases_done || forever ) {
1454 testCases_next();
1455 *trueFlagsPtr = 0;
1456 trueZ = trueFunction( testCases_a_float64 );
1457 trueFlags = *trueFlagsPtr;
1458 (void) testFlagsFunctionPtr();
1459 testZ = testFunction( testCases_a_float64 );
1460 testFlags = testFlagsFunctionPtr();
1461 --count;
1462 if ( count == 0 ) {
1463 checkEarlyExit();
1464 count = 10000;
1466 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1467 if ( ! checkNaNs
1468 && float64_is_signaling_nan( testCases_a_float64 ) ) {
1469 trueFlags |= float_flag_invalid;
1471 if ( ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1472 && ( ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1473 || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) )
1474 && ( trueFlags == float_flag_invalid )
1475 && ( testFlags == float_flag_invalid )
1477 /* no problem */
1479 else {
1480 ++errorCount;
1481 writeErrorFound( 10000 - count );
1482 writeInput_a_float64();
1483 fputs( " ", stdout );
1484 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags );
1485 fflush( stdout );
1486 if ( errorCount == maxErrorCount ) goto exit;
1490 exit:
1491 writeTestsPerformed( 10000 - count );
1495 #endif
1497 void
1498 test_a_float64_z_float32(
1499 float32 trueFunction( float64 ), float32 testFunction( float64 ) )
1501 int16 count;
1502 float32 trueZ, testZ;
1503 uint8 trueFlags, testFlags;
1505 errorCount = 0;
1506 tenthousandsCount = 0;
1507 count = 10000;
1508 testCases_initSequence( testCases_sequence_a_float64 );
1509 writeTestsTotal();
1510 while ( ! testCases_done || forever ) {
1511 testCases_next();
1512 *trueFlagsPtr = 0;
1513 trueZ = trueFunction( testCases_a_float64 );
1514 trueFlags = *trueFlagsPtr;
1515 (void) testFlagsFunctionPtr();
1516 testZ = testFunction( testCases_a_float64 );
1517 testFlags = testFlagsFunctionPtr();
1518 --count;
1519 if ( count == 0 ) {
1520 checkEarlyExit();
1521 count = 10000;
1523 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1524 if ( ! checkNaNs
1525 && float64_is_signaling_nan( testCases_a_float64 ) ) {
1526 trueFlags |= float_flag_invalid;
1528 if ( ! checkNaNs
1529 && float32_isNaN( trueZ )
1530 && float32_isNaN( testZ )
1531 && ! float32_is_signaling_nan( testZ )
1532 && ( trueFlags == testFlags )
1534 /* no problem */
1536 else {
1537 ++errorCount;
1538 writeErrorFound( 10000 - count );
1539 writeInput_a_float64();
1540 fputs( " ", stdout );
1541 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
1542 fflush( stdout );
1543 if ( errorCount == maxErrorCount ) goto exit;
1547 exit:
1548 writeTestsPerformed( 10000 - count );
1552 #ifdef FLOATX80
1554 void
1555 test_a_float64_z_floatx80(
1556 floatx80 trueFunction( float64 ), floatx80 testFunction( float64 ) )
1558 int16 count;
1559 floatx80 trueZ, testZ;
1560 uint8 trueFlags, testFlags;
1562 errorCount = 0;
1563 tenthousandsCount = 0;
1564 count = 10000;
1565 testCases_initSequence( testCases_sequence_a_float64 );
1566 writeTestsTotal();
1567 while ( ! testCases_done || forever ) {
1568 testCases_next();
1569 *trueFlagsPtr = 0;
1570 trueZ = trueFunction( testCases_a_float64 );
1571 trueFlags = *trueFlagsPtr;
1572 (void) testFlagsFunctionPtr();
1573 testZ = testFunction( testCases_a_float64 );
1574 testFlags = testFlagsFunctionPtr();
1575 --count;
1576 if ( count == 0 ) {
1577 checkEarlyExit();
1578 count = 10000;
1580 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1581 if ( ! checkNaNs
1582 && float64_is_signaling_nan( testCases_a_float64 ) ) {
1583 trueFlags |= float_flag_invalid;
1585 if ( ! checkNaNs
1586 && floatx80_isNaN( trueZ )
1587 && floatx80_isNaN( testZ )
1588 && ! floatx80_is_signaling_nan( testZ )
1589 && ( trueFlags == testFlags )
1591 /* no problem */
1593 else {
1594 ++errorCount;
1595 writeErrorFound( 10000 - count );
1596 writeInput_a_float64();
1597 fputs( "\n\t", stdout );
1598 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
1599 fflush( stdout );
1600 if ( errorCount == maxErrorCount ) goto exit;
1604 exit:
1605 writeTestsPerformed( 10000 - count );
1609 #endif
1611 #ifdef FLOAT128
1613 void
1614 test_a_float64_z_float128(
1615 float128 trueFunction( float64 ), float128 testFunction( float64 ) )
1617 int16 count;
1618 float128 trueZ, testZ;
1619 uint8 trueFlags, testFlags;
1621 errorCount = 0;
1622 tenthousandsCount = 0;
1623 count = 10000;
1624 testCases_initSequence( testCases_sequence_a_float64 );
1625 writeTestsTotal();
1626 while ( ! testCases_done || forever ) {
1627 testCases_next();
1628 *trueFlagsPtr = 0;
1629 trueZ = trueFunction( testCases_a_float64 );
1630 trueFlags = *trueFlagsPtr;
1631 (void) testFlagsFunctionPtr();
1632 testZ = testFunction( testCases_a_float64 );
1633 testFlags = testFlagsFunctionPtr();
1634 --count;
1635 if ( count == 0 ) {
1636 checkEarlyExit();
1637 count = 10000;
1639 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1640 if ( ! checkNaNs
1641 && float64_is_signaling_nan( testCases_a_float64 ) ) {
1642 trueFlags |= float_flag_invalid;
1644 if ( ! checkNaNs
1645 && float128_isNaN( trueZ )
1646 && float128_isNaN( testZ )
1647 && ! float128_is_signaling_nan( testZ )
1648 && ( trueFlags == testFlags )
1650 /* no problem */
1652 else {
1653 ++errorCount;
1654 writeErrorFound( 10000 - count );
1655 writeInput_a_float64();
1656 fputs( "\n\t", stdout );
1657 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
1658 fflush( stdout );
1659 if ( errorCount == maxErrorCount ) goto exit;
1663 exit:
1664 writeTestsPerformed( 10000 - count );
1668 #endif
1670 void
1671 test_az_float64(
1672 float64 trueFunction( float64 ), float64 testFunction( float64 ) )
1674 int16 count;
1675 float64 trueZ, testZ;
1676 uint8 trueFlags, testFlags;
1678 errorCount = 0;
1679 tenthousandsCount = 0;
1680 count = 10000;
1681 testCases_initSequence( testCases_sequence_a_float64 );
1682 writeTestsTotal();
1683 while ( ! testCases_done || forever ) {
1684 testCases_next();
1685 *trueFlagsPtr = 0;
1686 trueZ = trueFunction( testCases_a_float64 );
1687 trueFlags = *trueFlagsPtr;
1688 (void) testFlagsFunctionPtr();
1689 testZ = testFunction( testCases_a_float64 );
1690 testFlags = testFlagsFunctionPtr();
1691 --count;
1692 if ( count == 0 ) {
1693 checkEarlyExit();
1694 count = 10000;
1696 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1697 if ( ! checkNaNs
1698 && float64_is_signaling_nan( testCases_a_float64 ) ) {
1699 trueFlags |= float_flag_invalid;
1701 if ( ! checkNaNs
1702 && float64_isNaN( trueZ )
1703 && float64_isNaN( testZ )
1704 && ! float64_is_signaling_nan( testZ )
1705 && ( trueFlags == testFlags )
1707 /* no problem */
1709 else {
1710 ++errorCount;
1711 writeErrorFound( 10000 - count );
1712 writeInput_a_float64();
1713 fputs( " ", stdout );
1714 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
1715 fflush( stdout );
1716 if ( errorCount == maxErrorCount ) goto exit;
1720 exit:
1721 writeTestsPerformed( 10000 - count );
1725 void
1726 test_ab_float64_z_flag(
1727 flag trueFunction( float64, float64 ),
1728 flag testFunction( float64, float64 )
1731 int16 count;
1732 flag trueZ, testZ;
1733 uint8 trueFlags, testFlags;
1735 errorCount = 0;
1736 tenthousandsCount = 0;
1737 count = 10000;
1738 testCases_initSequence( testCases_sequence_ab_float64 );
1739 writeTestsTotal();
1740 while ( ! testCases_done || forever ) {
1741 testCases_next();
1742 *trueFlagsPtr = 0;
1743 trueZ = trueFunction( testCases_a_float64, testCases_b_float64 );
1744 trueFlags = *trueFlagsPtr;
1745 (void) testFlagsFunctionPtr();
1746 testZ = testFunction( testCases_a_float64, testCases_b_float64 );
1747 testFlags = testFlagsFunctionPtr();
1748 --count;
1749 if ( count == 0 ) {
1750 checkEarlyExit();
1751 count = 10000;
1753 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1754 if ( ! checkNaNs
1755 && ( float64_is_signaling_nan( testCases_a_float64 )
1756 || float64_is_signaling_nan( testCases_b_float64 ) )
1758 trueFlags |= float_flag_invalid;
1760 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1761 ++errorCount;
1762 writeErrorFound( 10000 - count );
1763 writeInputs_ab_float64();
1764 fputs( " ", stdout );
1765 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags );
1766 fflush( stdout );
1767 if ( errorCount == maxErrorCount ) goto exit;
1771 exit:
1772 writeTestsPerformed( 10000 - count );
1773 return;
1777 void
1778 test_abz_float64(
1779 float64 trueFunction( float64, float64 ),
1780 float64 testFunction( float64, float64 )
1783 int16 count;
1784 float64 trueZ, testZ;
1785 uint8 trueFlags, testFlags;
1787 errorCount = 0;
1788 tenthousandsCount = 0;
1789 count = 10000;
1790 testCases_initSequence( testCases_sequence_ab_float64 );
1791 writeTestsTotal();
1792 while ( ! testCases_done || forever ) {
1793 testCases_next();
1794 *trueFlagsPtr = 0;
1795 trueZ = trueFunction( testCases_a_float64, testCases_b_float64 );
1796 trueFlags = *trueFlagsPtr;
1797 (void) testFlagsFunctionPtr();
1798 testZ = testFunction( testCases_a_float64, testCases_b_float64 );
1799 testFlags = testFlagsFunctionPtr();
1800 --count;
1801 if ( count == 0 ) {
1802 checkEarlyExit();
1803 count = 10000;
1805 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1806 if ( ! checkNaNs
1807 && ( float64_is_signaling_nan( testCases_a_float64 )
1808 || float64_is_signaling_nan( testCases_b_float64 ) )
1810 trueFlags |= float_flag_invalid;
1812 if ( ! checkNaNs
1813 && float64_isNaN( trueZ )
1814 && float64_isNaN( testZ )
1815 && ! float64_is_signaling_nan( testZ )
1816 && ( trueFlags == testFlags )
1818 /* no problem */
1820 else {
1821 ++errorCount;
1822 writeErrorFound( 10000 - count );
1823 writeInputs_ab_float64();
1824 fputs( "\n\t", stdout );
1825 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
1826 fflush( stdout );
1827 if ( errorCount == maxErrorCount ) goto exit;
1831 exit:
1832 writeTestsPerformed( 10000 - count );
1833 return;
1837 #ifdef FLOATX80
1839 void
1840 test_a_floatx80_z_int32(
1841 int32 trueFunction( floatx80 ), int32 testFunction( floatx80 ) )
1843 int16 count;
1844 int32 trueZ, testZ;
1845 uint8 trueFlags, testFlags;
1847 errorCount = 0;
1848 tenthousandsCount = 0;
1849 count = 10000;
1850 testCases_initSequence( testCases_sequence_a_floatx80 );
1851 writeTestsTotal();
1852 while ( ! testCases_done || forever ) {
1853 testCases_next();
1854 *trueFlagsPtr = 0;
1855 trueZ = trueFunction( testCases_a_floatx80 );
1856 trueFlags = *trueFlagsPtr;
1857 (void) testFlagsFunctionPtr();
1858 testZ = testFunction( testCases_a_floatx80 );
1859 testFlags = testFlagsFunctionPtr();
1860 --count;
1861 if ( count == 0 ) {
1862 checkEarlyExit();
1863 count = 10000;
1865 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1866 if ( ! checkNaNs
1867 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
1868 trueFlags |= float_flag_invalid;
1870 if ( ( trueZ == 0x7FFFFFFF )
1871 && ( ( testZ == 0x7FFFFFFF )
1872 || ( testZ == (sbits32) 0x80000000 ) )
1873 && ( trueFlags == float_flag_invalid )
1874 && ( testFlags == float_flag_invalid )
1876 /* no problem */
1878 else {
1879 ++errorCount;
1880 writeErrorFound( 10000 - count );
1881 writeInput_a_floatx80();
1882 fputs( " ", stdout );
1883 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags );
1884 fflush( stdout );
1885 if ( errorCount == maxErrorCount ) goto exit;
1889 exit:
1890 writeTestsPerformed( 10000 - count );
1894 #ifdef BITS64
1896 void
1897 test_a_floatx80_z_int64(
1898 int64 trueFunction( floatx80 ), int64 testFunction( floatx80 ) )
1900 int16 count;
1901 int64 trueZ, testZ;
1902 uint8 trueFlags, testFlags;
1904 errorCount = 0;
1905 tenthousandsCount = 0;
1906 count = 10000;
1907 testCases_initSequence( testCases_sequence_a_floatx80 );
1908 writeTestsTotal();
1909 while ( ! testCases_done || forever ) {
1910 testCases_next();
1911 *trueFlagsPtr = 0;
1912 trueZ = trueFunction( testCases_a_floatx80 );
1913 trueFlags = *trueFlagsPtr;
1914 (void) testFlagsFunctionPtr();
1915 testZ = testFunction( testCases_a_floatx80 );
1916 testFlags = testFlagsFunctionPtr();
1917 --count;
1918 if ( count == 0 ) {
1919 checkEarlyExit();
1920 count = 10000;
1922 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1923 if ( ! checkNaNs
1924 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
1925 trueFlags |= float_flag_invalid;
1927 if ( ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1928 && ( ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1929 || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) )
1930 && ( trueFlags == float_flag_invalid )
1931 && ( testFlags == float_flag_invalid )
1933 /* no problem */
1935 else {
1936 ++errorCount;
1937 writeErrorFound( 10000 - count );
1938 writeInput_a_floatx80();
1939 fputs( " ", stdout );
1940 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags );
1941 fflush( stdout );
1942 if ( errorCount == maxErrorCount ) goto exit;
1946 exit:
1947 writeTestsPerformed( 10000 - count );
1951 #endif
1953 void
1954 test_a_floatx80_z_float32(
1955 float32 trueFunction( floatx80 ), float32 testFunction( floatx80 ) )
1957 int16 count;
1958 float32 trueZ, testZ;
1959 uint8 trueFlags, testFlags;
1961 errorCount = 0;
1962 tenthousandsCount = 0;
1963 count = 10000;
1964 testCases_initSequence( testCases_sequence_a_floatx80 );
1965 writeTestsTotal();
1966 while ( ! testCases_done || forever ) {
1967 testCases_next();
1968 *trueFlagsPtr = 0;
1969 trueZ = trueFunction( testCases_a_floatx80 );
1970 trueFlags = *trueFlagsPtr;
1971 (void) testFlagsFunctionPtr();
1972 testZ = testFunction( testCases_a_floatx80 );
1973 testFlags = testFlagsFunctionPtr();
1974 --count;
1975 if ( count == 0 ) {
1976 checkEarlyExit();
1977 count = 10000;
1979 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1980 if ( ! checkNaNs
1981 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
1982 trueFlags |= float_flag_invalid;
1984 if ( ! checkNaNs
1985 && float32_isNaN( trueZ )
1986 && float32_isNaN( testZ )
1987 && ! float32_is_signaling_nan( testZ )
1988 && ( trueFlags == testFlags )
1990 /* no problem */
1992 else {
1993 ++errorCount;
1994 writeErrorFound( 10000 - count );
1995 writeInput_a_floatx80();
1996 fputs( " ", stdout );
1997 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
1998 fflush( stdout );
1999 if ( errorCount == maxErrorCount ) goto exit;
2003 exit:
2004 writeTestsPerformed( 10000 - count );
2008 void
2009 test_a_floatx80_z_float64(
2010 float64 trueFunction( floatx80 ), float64 testFunction( floatx80 ) )
2012 int16 count;
2013 float64 trueZ, testZ;
2014 uint8 trueFlags, testFlags;
2016 errorCount = 0;
2017 tenthousandsCount = 0;
2018 count = 10000;
2019 testCases_initSequence( testCases_sequence_a_floatx80 );
2020 writeTestsTotal();
2021 while ( ! testCases_done || forever ) {
2022 testCases_next();
2023 *trueFlagsPtr = 0;
2024 trueZ = trueFunction( testCases_a_floatx80 );
2025 trueFlags = *trueFlagsPtr;
2026 (void) testFlagsFunctionPtr();
2027 testZ = testFunction( testCases_a_floatx80 );
2028 testFlags = testFlagsFunctionPtr();
2029 --count;
2030 if ( count == 0 ) {
2031 checkEarlyExit();
2032 count = 10000;
2034 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2035 if ( ! checkNaNs
2036 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
2037 trueFlags |= float_flag_invalid;
2039 if ( ! checkNaNs
2040 && float64_isNaN( trueZ )
2041 && float64_isNaN( testZ )
2042 && ! float64_is_signaling_nan( testZ )
2043 && ( trueFlags == testFlags )
2045 /* no problem */
2047 else {
2048 ++errorCount;
2049 writeErrorFound( 10000 - count );
2050 writeInput_a_floatx80();
2051 fputs( "\n\t", stdout );
2052 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
2053 fflush( stdout );
2054 if ( errorCount == maxErrorCount ) goto exit;
2058 exit:
2059 writeTestsPerformed( 10000 - count );
2063 #ifdef FLOAT128
2065 void
2066 test_a_floatx80_z_float128(
2067 float128 trueFunction( floatx80 ), float128 testFunction( floatx80 ) )
2069 int16 count;
2070 float128 trueZ, testZ;
2071 uint8 trueFlags, testFlags;
2073 errorCount = 0;
2074 tenthousandsCount = 0;
2075 count = 10000;
2076 testCases_initSequence( testCases_sequence_a_floatx80 );
2077 writeTestsTotal();
2078 while ( ! testCases_done || forever ) {
2079 testCases_next();
2080 *trueFlagsPtr = 0;
2081 trueZ = trueFunction( testCases_a_floatx80 );
2082 trueFlags = *trueFlagsPtr;
2083 (void) testFlagsFunctionPtr();
2084 testZ = testFunction( testCases_a_floatx80 );
2085 testFlags = testFlagsFunctionPtr();
2086 --count;
2087 if ( count == 0 ) {
2088 checkEarlyExit();
2089 count = 10000;
2091 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2092 if ( ! checkNaNs
2093 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
2094 trueFlags |= float_flag_invalid;
2096 if ( ! checkNaNs
2097 && float128_isNaN( trueZ )
2098 && float128_isNaN( testZ )
2099 && ! float128_is_signaling_nan( testZ )
2100 && ( trueFlags == testFlags )
2102 /* no problem */
2104 else {
2105 ++errorCount;
2106 writeErrorFound( 10000 - count );
2107 writeInput_a_floatx80();
2108 fputs( "\n\t", stdout );
2109 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
2110 fflush( stdout );
2111 if ( errorCount == maxErrorCount ) goto exit;
2115 exit:
2116 writeTestsPerformed( 10000 - count );
2120 #endif
2122 void
2123 test_az_floatx80(
2124 floatx80 trueFunction( floatx80 ), floatx80 testFunction( floatx80 ) )
2126 int16 count;
2127 floatx80 trueZ, testZ;
2128 uint8 trueFlags, testFlags;
2130 errorCount = 0;
2131 tenthousandsCount = 0;
2132 count = 10000;
2133 testCases_initSequence( testCases_sequence_a_floatx80 );
2134 writeTestsTotal();
2135 while ( ! testCases_done || forever ) {
2136 testCases_next();
2137 *trueFlagsPtr = 0;
2138 trueZ = trueFunction( testCases_a_floatx80 );
2139 trueFlags = *trueFlagsPtr;
2140 (void) testFlagsFunctionPtr();
2141 testZ = testFunction( testCases_a_floatx80 );
2142 testFlags = testFlagsFunctionPtr();
2143 --count;
2144 if ( count == 0 ) {
2145 checkEarlyExit();
2146 count = 10000;
2148 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2149 if ( ! checkNaNs
2150 && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
2151 trueFlags |= float_flag_invalid;
2153 if ( ! checkNaNs
2154 && floatx80_isNaN( trueZ )
2155 && floatx80_isNaN( testZ )
2156 && ! floatx80_is_signaling_nan( testZ )
2157 && ( trueFlags == testFlags )
2159 /* no problem */
2161 else {
2162 ++errorCount;
2163 writeErrorFound( 10000 - count );
2164 writeInput_a_floatx80();
2165 fputs( "\n\t", stdout );
2166 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
2167 fflush( stdout );
2168 if ( errorCount == maxErrorCount ) goto exit;
2172 exit:
2173 writeTestsPerformed( 10000 - count );
2177 void
2178 test_ab_floatx80_z_flag(
2179 flag trueFunction( floatx80, floatx80 ),
2180 flag testFunction( floatx80, floatx80 )
2183 int16 count;
2184 flag trueZ, testZ;
2185 uint8 trueFlags, testFlags;
2187 errorCount = 0;
2188 tenthousandsCount = 0;
2189 count = 10000;
2190 testCases_initSequence( testCases_sequence_ab_floatx80 );
2191 writeTestsTotal();
2192 while ( ! testCases_done || forever ) {
2193 testCases_next();
2194 *trueFlagsPtr = 0;
2195 trueZ = trueFunction( testCases_a_floatx80, testCases_b_floatx80 );
2196 trueFlags = *trueFlagsPtr;
2197 (void) testFlagsFunctionPtr();
2198 testZ = testFunction( testCases_a_floatx80, testCases_b_floatx80 );
2199 testFlags = testFlagsFunctionPtr();
2200 --count;
2201 if ( count == 0 ) {
2202 checkEarlyExit();
2203 count = 10000;
2205 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2206 if ( ! checkNaNs
2207 && ( floatx80_is_signaling_nan( testCases_a_floatx80 )
2208 || floatx80_is_signaling_nan( testCases_b_floatx80 ) )
2210 trueFlags |= float_flag_invalid;
2212 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2213 ++errorCount;
2214 writeErrorFound( 10000 - count );
2215 writeInputs_ab_floatx80();
2216 fputs( " ", stdout );
2217 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags );
2218 fflush( stdout );
2219 if ( errorCount == maxErrorCount ) goto exit;
2223 exit:
2224 writeTestsPerformed( 10000 - count );
2225 return;
2229 void
2230 test_abz_floatx80(
2231 floatx80 trueFunction( floatx80, floatx80 ),
2232 floatx80 testFunction( floatx80, floatx80 )
2235 int16 count;
2236 floatx80 trueZ, testZ;
2237 uint8 trueFlags, testFlags;
2239 errorCount = 0;
2240 tenthousandsCount = 0;
2241 count = 10000;
2242 testCases_initSequence( testCases_sequence_ab_floatx80 );
2243 writeTestsTotal();
2244 while ( ! testCases_done || forever ) {
2245 testCases_next();
2246 *trueFlagsPtr = 0;
2247 trueZ = trueFunction( testCases_a_floatx80, testCases_b_floatx80 );
2248 trueFlags = *trueFlagsPtr;
2249 (void) testFlagsFunctionPtr();
2250 testZ = testFunction( testCases_a_floatx80, testCases_b_floatx80 );
2251 testFlags = testFlagsFunctionPtr();
2252 --count;
2253 if ( count == 0 ) {
2254 checkEarlyExit();
2255 count = 10000;
2257 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2258 if ( ! checkNaNs
2259 && ( floatx80_is_signaling_nan( testCases_a_floatx80 )
2260 || floatx80_is_signaling_nan( testCases_b_floatx80 ) )
2262 trueFlags |= float_flag_invalid;
2264 if ( ! checkNaNs
2265 && floatx80_isNaN( trueZ )
2266 && floatx80_isNaN( testZ )
2267 && ! floatx80_is_signaling_nan( testZ )
2268 && ( trueFlags == testFlags )
2270 /* no problem */
2272 else {
2273 ++errorCount;
2274 writeErrorFound( 10000 - count );
2275 writeInputs_ab_floatx80();
2276 fputs( "\n\t", stdout );
2277 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
2278 fflush( stdout );
2279 if ( errorCount == maxErrorCount ) goto exit;
2283 exit:
2284 writeTestsPerformed( 10000 - count );
2285 return;
2289 #endif
2291 #ifdef FLOAT128
2293 void
2294 test_a_float128_z_int32(
2295 int32 trueFunction( float128 ), int32 testFunction( float128 ) )
2297 int16 count;
2298 int32 trueZ, testZ;
2299 uint8 trueFlags, testFlags;
2301 errorCount = 0;
2302 tenthousandsCount = 0;
2303 count = 10000;
2304 testCases_initSequence( testCases_sequence_a_float128 );
2305 writeTestsTotal();
2306 while ( ! testCases_done || forever ) {
2307 testCases_next();
2308 *trueFlagsPtr = 0;
2309 trueZ = trueFunction( testCases_a_float128 );
2310 trueFlags = *trueFlagsPtr;
2311 (void) testFlagsFunctionPtr();
2312 testZ = testFunction( testCases_a_float128 );
2313 testFlags = testFlagsFunctionPtr();
2314 --count;
2315 if ( count == 0 ) {
2316 checkEarlyExit();
2317 count = 10000;
2319 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2320 if ( ! checkNaNs
2321 && float128_is_signaling_nan( testCases_a_float128 ) ) {
2322 trueFlags |= float_flag_invalid;
2324 if ( ( trueZ == 0x7FFFFFFF )
2325 && ( ( testZ == 0x7FFFFFFF )
2326 || ( testZ == (sbits32) 0x80000000 ) )
2327 && ( trueFlags == float_flag_invalid )
2328 && ( testFlags == float_flag_invalid )
2330 /* no problem */
2332 else {
2333 ++errorCount;
2334 writeErrorFound( 10000 - count );
2335 writeInput_a_float128();
2336 fputs( " ", stdout );
2337 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags );
2338 fflush( stdout );
2339 if ( errorCount == maxErrorCount ) goto exit;
2343 exit:
2344 writeTestsPerformed( 10000 - count );
2348 #ifdef BITS64
2350 void
2351 test_a_float128_z_int64(
2352 int64 trueFunction( float128 ), int64 testFunction( float128 ) )
2354 int16 count;
2355 int64 trueZ, testZ;
2356 uint8 trueFlags, testFlags;
2358 errorCount = 0;
2359 tenthousandsCount = 0;
2360 count = 10000;
2361 testCases_initSequence( testCases_sequence_a_float128 );
2362 writeTestsTotal();
2363 while ( ! testCases_done || forever ) {
2364 testCases_next();
2365 *trueFlagsPtr = 0;
2366 trueZ = trueFunction( testCases_a_float128 );
2367 trueFlags = *trueFlagsPtr;
2368 (void) testFlagsFunctionPtr();
2369 testZ = testFunction( testCases_a_float128 );
2370 testFlags = testFlagsFunctionPtr();
2371 --count;
2372 if ( count == 0 ) {
2373 checkEarlyExit();
2374 count = 10000;
2376 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2377 if ( ! checkNaNs
2378 && float128_is_signaling_nan( testCases_a_float128 ) ) {
2379 trueFlags |= float_flag_invalid;
2381 if ( ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
2382 && ( ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
2383 || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) )
2384 && ( trueFlags == float_flag_invalid )
2385 && ( testFlags == float_flag_invalid )
2387 /* no problem */
2389 else {
2390 ++errorCount;
2391 writeErrorFound( 10000 - count );
2392 writeInput_a_float128();
2393 fputs( "\n\t", stdout );
2394 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags );
2395 fflush( stdout );
2396 if ( errorCount == maxErrorCount ) goto exit;
2400 exit:
2401 writeTestsPerformed( 10000 - count );
2405 #endif
2407 void
2408 test_a_float128_z_float32(
2409 float32 trueFunction( float128 ), float32 testFunction( float128 ) )
2411 int16 count;
2412 float32 trueZ, testZ;
2413 uint8 trueFlags, testFlags;
2415 errorCount = 0;
2416 tenthousandsCount = 0;
2417 count = 10000;
2418 testCases_initSequence( testCases_sequence_a_float128 );
2419 writeTestsTotal();
2420 while ( ! testCases_done || forever ) {
2421 testCases_next();
2422 *trueFlagsPtr = 0;
2423 trueZ = trueFunction( testCases_a_float128 );
2424 trueFlags = *trueFlagsPtr;
2425 (void) testFlagsFunctionPtr();
2426 testZ = testFunction( testCases_a_float128 );
2427 testFlags = testFlagsFunctionPtr();
2428 --count;
2429 if ( count == 0 ) {
2430 checkEarlyExit();
2431 count = 10000;
2433 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2434 if ( ! checkNaNs
2435 && float128_is_signaling_nan( testCases_a_float128 ) ) {
2436 trueFlags |= float_flag_invalid;
2438 if ( ! checkNaNs
2439 && float32_isNaN( trueZ )
2440 && float32_isNaN( testZ )
2441 && ! float32_is_signaling_nan( testZ )
2442 && ( trueFlags == testFlags )
2444 /* no problem */
2446 else {
2447 ++errorCount;
2448 writeErrorFound( 10000 - count );
2449 writeInput_a_float128();
2450 fputs( " ", stdout );
2451 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
2452 fflush( stdout );
2453 if ( errorCount == maxErrorCount ) goto exit;
2457 exit:
2458 writeTestsPerformed( 10000 - count );
2462 void
2463 test_a_float128_z_float64(
2464 float64 trueFunction( float128 ), float64 testFunction( float128 ) )
2466 int16 count;
2467 float64 trueZ, testZ;
2468 uint8 trueFlags, testFlags;
2470 errorCount = 0;
2471 tenthousandsCount = 0;
2472 count = 10000;
2473 testCases_initSequence( testCases_sequence_a_float128 );
2474 writeTestsTotal();
2475 while ( ! testCases_done || forever ) {
2476 testCases_next();
2477 *trueFlagsPtr = 0;
2478 trueZ = trueFunction( testCases_a_float128 );
2479 trueFlags = *trueFlagsPtr;
2480 (void) testFlagsFunctionPtr();
2481 testZ = testFunction( testCases_a_float128 );
2482 testFlags = testFlagsFunctionPtr();
2483 --count;
2484 if ( count == 0 ) {
2485 checkEarlyExit();
2486 count = 10000;
2488 if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2489 if ( ! checkNaNs
2490 && float128_is_signaling_nan( testCases_a_float128 ) ) {
2491 trueFlags |= float_flag_invalid;
2493 if ( ! checkNaNs
2494 && float64_isNaN( trueZ )
2495 && float64_isNaN( testZ )
2496 && ! float64_is_signaling_nan( testZ )
2497 && ( trueFlags == testFlags )
2499 /* no problem */
2501 else {
2502 ++errorCount;
2503 writeErrorFound( 10000 - count );
2504 writeInput_a_float128();
2505 fputs( "\n\t", stdout );
2506 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
2507 fflush( stdout );
2508 if ( errorCount == maxErrorCount ) goto exit;
2512 exit:
2513 writeTestsPerformed( 10000 - count );
2517 #ifdef FLOATX80
2519 void
2520 test_a_float128_z_floatx80(
2521 floatx80 trueFunction( float128 ), floatx80 testFunction( float128 ) )
2523 int16 count;
2524 floatx80 trueZ, testZ;
2525 uint8 trueFlags, testFlags;
2527 errorCount = 0;
2528 tenthousandsCount = 0;
2529 count = 10000;
2530 testCases_initSequence( testCases_sequence_a_float128 );
2531 writeTestsTotal();
2532 while ( ! testCases_done || forever ) {
2533 testCases_next();
2534 *trueFlagsPtr = 0;
2535 trueZ = trueFunction( testCases_a_float128 );
2536 trueFlags = *trueFlagsPtr;
2537 (void) testFlagsFunctionPtr();
2538 testZ = testFunction( testCases_a_float128 );
2539 testFlags = testFlagsFunctionPtr();
2540 --count;
2541 if ( count == 0 ) {
2542 checkEarlyExit();
2543 count = 10000;
2545 if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2546 if ( ! checkNaNs
2547 && float128_is_signaling_nan( testCases_a_float128 ) ) {
2548 trueFlags |= float_flag_invalid;
2550 if ( ! checkNaNs
2551 && floatx80_isNaN( trueZ )
2552 && floatx80_isNaN( testZ )
2553 && ! floatx80_is_signaling_nan( testZ )
2554 && ( trueFlags == testFlags )
2556 /* no problem */
2558 else {
2559 ++errorCount;
2560 writeErrorFound( 10000 - count );
2561 writeInput_a_float128();
2562 fputs( "\n\t", stdout );
2563 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
2564 fflush( stdout );
2565 if ( errorCount == maxErrorCount ) goto exit;
2569 exit:
2570 writeTestsPerformed( 10000 - count );
2574 #endif
2576 void
2577 test_az_float128(
2578 float128 trueFunction( float128 ), float128 testFunction( float128 ) )
2580 int16 count;
2581 float128 trueZ, testZ;
2582 uint8 trueFlags, testFlags;
2584 errorCount = 0;
2585 tenthousandsCount = 0;
2586 count = 10000;
2587 testCases_initSequence( testCases_sequence_a_float128 );
2588 writeTestsTotal();
2589 while ( ! testCases_done || forever ) {
2590 testCases_next();
2591 *trueFlagsPtr = 0;
2592 trueZ = trueFunction( testCases_a_float128 );
2593 trueFlags = *trueFlagsPtr;
2594 (void) testFlagsFunctionPtr();
2595 testZ = testFunction( testCases_a_float128 );
2596 testFlags = testFlagsFunctionPtr();
2597 --count;
2598 if ( count == 0 ) {
2599 checkEarlyExit();
2600 count = 10000;
2602 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2603 if ( ! checkNaNs
2604 && float128_is_signaling_nan( testCases_a_float128 ) ) {
2605 trueFlags |= float_flag_invalid;
2607 if ( ! checkNaNs
2608 && float128_isNaN( trueZ )
2609 && float128_isNaN( testZ )
2610 && ! float128_is_signaling_nan( testZ )
2611 && ( trueFlags == testFlags )
2613 /* no problem */
2615 else {
2616 ++errorCount;
2617 writeErrorFound( 10000 - count );
2618 writeInput_a_float128();
2619 fputs( "\n\t", stdout );
2620 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
2621 fflush( stdout );
2622 if ( errorCount == maxErrorCount ) goto exit;
2626 exit:
2627 writeTestsPerformed( 10000 - count );
2631 void
2632 test_ab_float128_z_flag(
2633 flag trueFunction( float128, float128 ),
2634 flag testFunction( float128, float128 )
2637 int16 count;
2638 flag trueZ, testZ;
2639 uint8 trueFlags, testFlags;
2641 errorCount = 0;
2642 tenthousandsCount = 0;
2643 count = 10000;
2644 testCases_initSequence( testCases_sequence_ab_float128 );
2645 writeTestsTotal();
2646 while ( ! testCases_done || forever ) {
2647 testCases_next();
2648 *trueFlagsPtr = 0;
2649 trueZ = trueFunction( testCases_a_float128, testCases_b_float128 );
2650 trueFlags = *trueFlagsPtr;
2651 (void) testFlagsFunctionPtr();
2652 testZ = testFunction( testCases_a_float128, testCases_b_float128 );
2653 testFlags = testFlagsFunctionPtr();
2654 --count;
2655 if ( count == 0 ) {
2656 checkEarlyExit();
2657 count = 10000;
2659 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2660 if ( ! checkNaNs
2661 && ( float128_is_signaling_nan( testCases_a_float128 )
2662 || float128_is_signaling_nan( testCases_b_float128 ) )
2664 trueFlags |= float_flag_invalid;
2666 if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2667 ++errorCount;
2668 writeErrorFound( 10000 - count );
2669 writeInputs_ab_float128();
2670 fputs( "\n\t", stdout );
2671 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags );
2672 fflush( stdout );
2673 if ( errorCount == maxErrorCount ) goto exit;
2677 exit:
2678 writeTestsPerformed( 10000 - count );
2679 return;
2683 void
2684 test_abz_float128(
2685 float128 trueFunction( float128, float128 ),
2686 float128 testFunction( float128, float128 )
2689 int16 count;
2690 float128 trueZ, testZ;
2691 uint8 trueFlags, testFlags;
2693 errorCount = 0;
2694 tenthousandsCount = 0;
2695 count = 10000;
2696 testCases_initSequence( testCases_sequence_ab_float128 );
2697 writeTestsTotal();
2698 while ( ! testCases_done || forever ) {
2699 testCases_next();
2700 *trueFlagsPtr = 0;
2701 trueZ = trueFunction( testCases_a_float128, testCases_b_float128 );
2702 trueFlags = *trueFlagsPtr;
2703 (void) testFlagsFunctionPtr();
2704 testZ = testFunction( testCases_a_float128, testCases_b_float128 );
2705 testFlags = testFlagsFunctionPtr();
2706 --count;
2707 if ( count == 0 ) {
2708 checkEarlyExit();
2709 count = 10000;
2711 if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2712 if ( ! checkNaNs
2713 && ( float128_is_signaling_nan( testCases_a_float128 )
2714 || float128_is_signaling_nan( testCases_b_float128 ) )
2716 trueFlags |= float_flag_invalid;
2718 if ( ! checkNaNs
2719 && float128_isNaN( trueZ )
2720 && float128_isNaN( testZ )
2721 && ! float128_is_signaling_nan( testZ )
2722 && ( trueFlags == testFlags )
2724 /* no problem */
2726 else {
2727 ++errorCount;
2728 writeErrorFound( 10000 - count );
2729 writeInputs_ab_float128();
2730 fputs( "\n\t", stdout );
2731 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
2732 fflush( stdout );
2733 if ( errorCount == maxErrorCount ) goto exit;
2737 exit:
2738 writeTestsPerformed( 10000 - count );
2739 return;
2743 #endif