xref: /netbsd-src/regress/lib/libc/ieeefp/testfloat/testLoops.c (revision ce099b40997c43048fb78bd578195f81d2456523)
1*ce099b40Smartin /*	$NetBSD: testLoops.c,v 1.5 2008/04/28 20:23:04 martin Exp $	*/
289f51f80Sross 
389f51f80Sross /* This is a derivative work. */
489f51f80Sross 
589f51f80Sross /*-
689f51f80Sross  * Copyright (c) 2001 The NetBSD Foundation, Inc.
789f51f80Sross  * All rights reserved.
889f51f80Sross  *
989f51f80Sross  * This code is derived from software contributed to The NetBSD Foundation
1089f51f80Sross  * by Ross Harvey.
1189f51f80Sross  *
1289f51f80Sross  * Redistribution and use in source and binary forms, with or without
1389f51f80Sross  * modification, are permitted provided that the following conditions
1489f51f80Sross  * are met:
1589f51f80Sross  * 1. Redistributions of source code must retain the above copyright
1689f51f80Sross  *    notice, this list of conditions and the following disclaimer.
1789f51f80Sross  * 2. Redistributions in binary form must reproduce the above copyright
1889f51f80Sross  *    notice, this list of conditions and the following disclaimer in the
1989f51f80Sross  *    documentation and/or other materials provided with the distribution.
2089f51f80Sross  *
2189f51f80Sross  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2289f51f80Sross  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2389f51f80Sross  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2489f51f80Sross  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2589f51f80Sross  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2689f51f80Sross  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2789f51f80Sross  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2889f51f80Sross  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2989f51f80Sross  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3089f51f80Sross  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3189f51f80Sross  * POSSIBILITY OF SUCH DAMAGE.
3289f51f80Sross  */
33122b058aSross 
34122b058aSross /*
35122b058aSross ===============================================================================
36122b058aSross 
37122b058aSross This C source file is part of TestFloat, Release 2a, a package of programs
38122b058aSross for testing the correctness of floating-point arithmetic complying to the
39122b058aSross IEC/IEEE Standard for Floating-Point.
40122b058aSross 
41122b058aSross Written by John R. Hauser.  More information is available through the Web
42122b058aSross page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
43122b058aSross 
44122b058aSross THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
45122b058aSross has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
46122b058aSross TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
47122b058aSross PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
48122b058aSross AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
49122b058aSross 
50122b058aSross Derivative works are acceptable, even for commercial purposes, so long as
51122b058aSross (1) they include prominent notice that the work is derivative, and (2) they
52122b058aSross include prominent notice akin to these four paragraphs for those parts of
53122b058aSross this code that are retained.
54122b058aSross 
55122b058aSross ===============================================================================
56122b058aSross */
57122b058aSross 
58122b058aSross #include <stdlib.h>
59122b058aSross #include <stdio.h>
60122b058aSross #include "milieu.h"
61122b058aSross #include "softfloat.h"
62122b058aSross #include "testCases.h"
63122b058aSross #include "writeHex.h"
64122b058aSross #include "testLoops.h"
65122b058aSross 
66122b058aSross volatile flag stop = FALSE;
67122b058aSross 
685550be01Sross const char *trueName, *testName;
69122b058aSross flag forever, errorStop;
70122b058aSross uint32 maxErrorCount = 0;
71122b058aSross flag checkNaNs = FALSE;
72122b058aSross int8 *trueFlagsPtr;
73122b058aSross int8 ( *testFlagsFunctionPtr )( void );
745550be01Sross const char *functionName;
755550be01Sross const char *roundingPrecisionName, *roundingModeName, *tininessModeName;
76122b058aSross flag anyErrors = FALSE;
77122b058aSross 
writeFunctionName(FILE * stream)78122b058aSross void writeFunctionName( FILE *stream )
79122b058aSross {
80122b058aSross 
81122b058aSross     fputs( functionName, stream );
82122b058aSross     if ( roundingModeName ) {
83122b058aSross         if ( roundingPrecisionName ) {
84122b058aSross             fputs( ", precision ", stream );
85122b058aSross             fputs( roundingPrecisionName, stream );
86122b058aSross         }
87122b058aSross         fputs( ", rounding ", stream );
88122b058aSross         fputs( roundingModeName, stream );
89122b058aSross         if ( tininessModeName ) {
90122b058aSross             fputs( ", tininess ", stream );
91122b058aSross             fputs( tininessModeName, stream );
92122b058aSross             fputs( " rounding", stream );
93122b058aSross         }
94122b058aSross     }
95122b058aSross 
96122b058aSross }
97122b058aSross 
exitWithStatus(void)98122b058aSross void exitWithStatus( void )
99122b058aSross {
100122b058aSross 
101122b058aSross     exit( anyErrors ? EXIT_FAILURE : EXIT_SUCCESS );
102122b058aSross 
103122b058aSross }
104122b058aSross 
105122b058aSross static uint32 tenthousandsCount, errorCount = 0;
106122b058aSross 
writeTestsTotal(void)107122b058aSross static void writeTestsTotal( void )
108122b058aSross {
109122b058aSross 
110122b058aSross     if ( forever ) {
111122b058aSross         fputs( "Unbounded tests.\n", stderr );
112122b058aSross     }
113122b058aSross     else {
1145550be01Sross         fprintf( stderr, "%d tests total.\n", testCases_total );
115122b058aSross     }
116122b058aSross 
117122b058aSross }
118122b058aSross 
writeTestsPerformed(int16 count)119122b058aSross static void writeTestsPerformed( int16 count )
120122b058aSross {
121122b058aSross 
122122b058aSross     if ( tenthousandsCount ) {
123122b058aSross         fprintf(
1245550be01Sross             stderr, "%d%04d tests performed", tenthousandsCount, count );
125122b058aSross     }
126122b058aSross     else {
1275550be01Sross         fprintf( stderr, "%d tests performed", count );
128122b058aSross     }
129122b058aSross     if ( errorCount ) {
130122b058aSross         fprintf(
131122b058aSross             stderr,
132122b058aSross             "; %d error%s found.\n",
133122b058aSross             errorCount,
134122b058aSross             ( errorCount == 1 ) ? "" : "s"
135122b058aSross         );
136122b058aSross     }
137122b058aSross     else {
138122b058aSross         fputs( ".\n", stderr );
139122b058aSross         fputs( "No errors found in ", stdout );
140122b058aSross         writeFunctionName( stdout );
141122b058aSross         fputs( ".\n", stdout );
142122b058aSross         fflush( stdout );
143122b058aSross     }
144122b058aSross 
145122b058aSross }
146122b058aSross 
checkEarlyExit(void)147122b058aSross static void checkEarlyExit( void )
148122b058aSross {
149122b058aSross 
150122b058aSross     ++tenthousandsCount;
151122b058aSross     if ( stop ) {
152122b058aSross         writeTestsPerformed( 0 );
153122b058aSross         exitWithStatus();
154122b058aSross     }
1555550be01Sross     fprintf( stderr, "%3d0000", tenthousandsCount );
156122b058aSross 
157122b058aSross }
158122b058aSross 
writeErrorFound(int16 count)159122b058aSross static void writeErrorFound( int16 count )
160122b058aSross {
161122b058aSross 
162122b058aSross     if ( errorCount == 1 ) {
163122b058aSross         fputs( "Errors found in ", stdout );
164122b058aSross         writeFunctionName( stdout );
165122b058aSross         fputs( ":\n", stdout );
166122b058aSross     }
167122b058aSross     if ( stop ) {
168122b058aSross         writeTestsPerformed( count );
169122b058aSross         exitWithStatus();
170122b058aSross     }
171122b058aSross     anyErrors = TRUE;
172122b058aSross 
173122b058aSross }
174122b058aSross 
writeInput_a_int32(void)175122b058aSross INLINE void writeInput_a_int32( void )
176122b058aSross {
177122b058aSross 
178122b058aSross     writeHex_bits32( testCases_a_int32, stdout );
179122b058aSross 
180122b058aSross }
181122b058aSross 
182122b058aSross #ifdef BITS64
183122b058aSross 
writeInput_a_int64(void)184122b058aSross INLINE void writeInput_a_int64( void )
185122b058aSross {
186122b058aSross 
187122b058aSross     writeHex_bits64( testCases_a_int64, stdout );
188122b058aSross 
189122b058aSross }
190122b058aSross 
191122b058aSross #endif
192122b058aSross 
writeInput_a_float32(void)193122b058aSross INLINE void writeInput_a_float32( void )
194122b058aSross {
195122b058aSross 
196122b058aSross     writeHex_float32( testCases_a_float32, stdout );
197122b058aSross 
198122b058aSross }
199122b058aSross 
writeInputs_ab_float32(void)200122b058aSross static void writeInputs_ab_float32( void )
201122b058aSross {
202122b058aSross 
203122b058aSross     writeHex_float32( testCases_a_float32, stdout );
204122b058aSross     fputs( "  ", stdout );
205122b058aSross     writeHex_float32( testCases_b_float32, stdout );
206122b058aSross 
207122b058aSross }
208122b058aSross 
writeInput_a_float64(void)209122b058aSross INLINE void writeInput_a_float64( void )
210122b058aSross {
211122b058aSross 
212122b058aSross     writeHex_float64( testCases_a_float64, stdout );
213122b058aSross 
214122b058aSross }
215122b058aSross 
writeInputs_ab_float64(void)216122b058aSross static void writeInputs_ab_float64( void )
217122b058aSross {
218122b058aSross 
219122b058aSross     writeHex_float64( testCases_a_float64, stdout );
220122b058aSross     fputs( "  ", stdout );
221122b058aSross     writeHex_float64( testCases_b_float64, stdout );
222122b058aSross 
223122b058aSross }
224122b058aSross 
225122b058aSross #ifdef FLOATX80
226122b058aSross 
writeInput_a_floatx80(void)227122b058aSross INLINE void writeInput_a_floatx80( void )
228122b058aSross {
229122b058aSross 
230122b058aSross     writeHex_floatx80( testCases_a_floatx80, stdout );
231122b058aSross 
232122b058aSross }
233122b058aSross 
writeInputs_ab_floatx80(void)234122b058aSross static void writeInputs_ab_floatx80( void )
235122b058aSross {
236122b058aSross 
237122b058aSross     writeHex_floatx80( testCases_a_floatx80, stdout );
238122b058aSross     fputs( "  ", stdout );
239122b058aSross     writeHex_floatx80( testCases_b_floatx80, stdout );
240122b058aSross 
241122b058aSross }
242122b058aSross 
243122b058aSross #endif
244122b058aSross 
245122b058aSross #ifdef FLOAT128
246122b058aSross 
writeInput_a_float128(void)247122b058aSross INLINE void writeInput_a_float128( void )
248122b058aSross {
249122b058aSross 
250122b058aSross     writeHex_float128( testCases_a_float128, stdout );
251122b058aSross 
252122b058aSross }
253122b058aSross 
writeInputs_ab_float128(void)254122b058aSross static void writeInputs_ab_float128( void )
255122b058aSross {
256122b058aSross 
257122b058aSross     writeHex_float128( testCases_a_float128, stdout );
258122b058aSross     fputs( "  ", stdout );
259122b058aSross     writeHex_float128( testCases_b_float128, stdout );
260122b058aSross 
261122b058aSross }
262122b058aSross 
263122b058aSross #endif
264122b058aSross 
265122b058aSross static void
writeOutputs_z_flag(flag trueZ,uint8 trueFlags,flag testZ,uint8 testFlags)266122b058aSross  writeOutputs_z_flag(
267122b058aSross      flag trueZ, uint8 trueFlags, flag testZ, uint8 testFlags )
268122b058aSross {
269122b058aSross 
270122b058aSross     fputs( trueName, stdout );
271122b058aSross     fputs( ": ", stdout );
272122b058aSross     writeHex_flag( trueZ, stdout );
273122b058aSross     fputc( ' ', stdout );
274122b058aSross     writeHex_float_flags( trueFlags, stdout );
275122b058aSross     fputs( "  ", stdout );
276122b058aSross     fputs( testName, stdout );
277122b058aSross     fputs( ": ", stdout );
278122b058aSross     writeHex_flag( testZ, stdout );
279122b058aSross     fputc( ' ', stdout );
280122b058aSross     writeHex_float_flags( testFlags, stdout );
281122b058aSross     fputc( '\n', stdout );
282122b058aSross 
283122b058aSross }
284122b058aSross 
285122b058aSross static void
writeOutputs_z_int32(int32 trueZ,uint8 trueFlags,int32 testZ,uint8 testFlags)286122b058aSross  writeOutputs_z_int32(
287122b058aSross      int32 trueZ, uint8 trueFlags, int32 testZ, uint8 testFlags )
288122b058aSross {
289122b058aSross 
290122b058aSross     fputs( trueName, stdout );
291122b058aSross     fputs( ": ", stdout );
292122b058aSross     writeHex_bits32( trueZ, stdout );
293122b058aSross     fputc( ' ', stdout );
294122b058aSross     writeHex_float_flags( trueFlags, stdout );
295122b058aSross     fputs( "  ", stdout );
296122b058aSross     fputs( testName, stdout );
297122b058aSross     fputs( ": ", stdout );
298122b058aSross     writeHex_bits32( testZ, stdout );
299122b058aSross     fputc( ' ', stdout );
300122b058aSross     writeHex_float_flags( testFlags, stdout );
301122b058aSross     fputc( '\n', stdout );
302122b058aSross 
303122b058aSross }
304122b058aSross 
305122b058aSross #ifdef BITS64
306122b058aSross 
307122b058aSross static void
writeOutputs_z_int64(int64 trueZ,uint8 trueFlags,int64 testZ,uint8 testFlags)308122b058aSross  writeOutputs_z_int64(
309122b058aSross      int64 trueZ, uint8 trueFlags, int64 testZ, uint8 testFlags )
310122b058aSross {
311122b058aSross 
312122b058aSross     fputs( trueName, stdout );
313122b058aSross     fputs( ": ", stdout );
314122b058aSross     writeHex_bits64( trueZ, stdout );
315122b058aSross     fputc( ' ', stdout );
316122b058aSross     writeHex_float_flags( trueFlags, stdout );
317122b058aSross     fputs( "  ", stdout );
318122b058aSross     fputs( testName, stdout );
319122b058aSross     fputs( ": ", stdout );
320122b058aSross     writeHex_bits64( testZ, stdout );
321122b058aSross     fputc( ' ', stdout );
322122b058aSross     writeHex_float_flags( testFlags, stdout );
323122b058aSross     fputc( '\n', stdout );
324122b058aSross 
325122b058aSross }
326122b058aSross 
327122b058aSross #endif
328122b058aSross 
329122b058aSross static void
writeOutputs_z_float32(float32 trueZ,uint8 trueFlags,float32 testZ,uint8 testFlags)330122b058aSross  writeOutputs_z_float32(
331122b058aSross      float32 trueZ, uint8 trueFlags, float32 testZ, uint8 testFlags )
332122b058aSross {
333122b058aSross 
334122b058aSross     fputs( trueName, stdout );
335122b058aSross     fputs( ": ", stdout );
336122b058aSross     writeHex_float32( trueZ, stdout );
337122b058aSross     fputc( ' ', stdout );
338122b058aSross     writeHex_float_flags( trueFlags, stdout );
339122b058aSross     fputs( "  ", stdout );
340122b058aSross     fputs( testName, stdout );
341122b058aSross     fputs( ": ", stdout );
342122b058aSross     writeHex_float32( testZ, stdout );
343122b058aSross     fputc( ' ', stdout );
344122b058aSross     writeHex_float_flags( testFlags, stdout );
345122b058aSross     fputc( '\n', stdout );
346122b058aSross 
347122b058aSross }
348122b058aSross 
349122b058aSross static void
writeOutputs_z_float64(float64 trueZ,uint8 trueFlags,float64 testZ,uint8 testFlags)350122b058aSross  writeOutputs_z_float64(
351122b058aSross      float64 trueZ, uint8 trueFlags, float64 testZ, uint8 testFlags )
352122b058aSross {
353122b058aSross 
354122b058aSross     fputs( trueName, stdout );
355122b058aSross     fputs( ": ", stdout );
356122b058aSross     writeHex_float64( trueZ, stdout );
357122b058aSross     fputc( ' ', stdout );
358122b058aSross     writeHex_float_flags( trueFlags, stdout );
359122b058aSross     fputs( "  ", stdout );
360122b058aSross     fputs( testName, stdout );
361122b058aSross     fputs( ": ", stdout );
362122b058aSross     writeHex_float64( testZ, stdout );
363122b058aSross     fputc( ' ', stdout );
364122b058aSross     writeHex_float_flags( testFlags, stdout );
365122b058aSross     fputc( '\n', stdout );
366122b058aSross 
367122b058aSross }
368122b058aSross 
369122b058aSross #ifdef FLOATX80
370122b058aSross 
371122b058aSross static void
writeOutputs_z_floatx80(floatx80 trueZ,uint8 trueFlags,floatx80 testZ,uint8 testFlags)372122b058aSross  writeOutputs_z_floatx80(
373122b058aSross      floatx80 trueZ, uint8 trueFlags, floatx80 testZ, uint8 testFlags )
374122b058aSross {
375122b058aSross 
376122b058aSross     fputs( trueName, stdout );
377122b058aSross     fputs( ": ", stdout );
378122b058aSross     writeHex_floatx80( trueZ, stdout );
379122b058aSross     fputc( ' ', stdout );
380122b058aSross     writeHex_float_flags( trueFlags, stdout );
381122b058aSross     fputs( "  ", stdout );
382122b058aSross     fputs( testName, stdout );
383122b058aSross     fputs( ": ", stdout );
384122b058aSross     writeHex_floatx80( testZ, stdout );
385122b058aSross     fputc( ' ', stdout );
386122b058aSross     writeHex_float_flags( testFlags, stdout );
387122b058aSross     fputc( '\n', stdout );
388122b058aSross 
389122b058aSross }
390122b058aSross 
391122b058aSross #endif
392122b058aSross 
393122b058aSross #ifdef FLOAT128
394122b058aSross 
395122b058aSross static void
writeOutputs_z_float128(float128 trueZ,uint8 trueFlags,float128 testZ,uint8 testFlags)396122b058aSross  writeOutputs_z_float128(
397122b058aSross      float128 trueZ, uint8 trueFlags, float128 testZ, uint8 testFlags )
398122b058aSross {
399122b058aSross 
400122b058aSross     fputs( trueName, stdout );
401122b058aSross     fputs( ": ", stdout );
402122b058aSross     writeHex_float128( trueZ, stdout );
403122b058aSross     fputc( ' ', stdout );
404122b058aSross     writeHex_float_flags( trueFlags, stdout );
405122b058aSross     fputs( "\n\t", stdout );
406122b058aSross     fputs( testName, stdout );
407122b058aSross     fputs( ": ", stdout );
408122b058aSross     writeHex_float128( testZ, stdout );
409122b058aSross     fputc( ' ', stdout );
410122b058aSross     writeHex_float_flags( testFlags, stdout );
411122b058aSross     fputc( '\n', stdout );
412122b058aSross 
413122b058aSross }
414122b058aSross 
415122b058aSross #endif
416122b058aSross 
float32_isNaN(float32 a)417122b058aSross INLINE flag float32_isNaN( float32 a )
418122b058aSross {
419122b058aSross 
420122b058aSross     return 0x7F800000 < ( a & 0x7FFFFFFF );
421122b058aSross 
422122b058aSross }
423122b058aSross 
424122b058aSross #ifdef BITS64
425122b058aSross 
float64_same(float64 a,float64 b)426122b058aSross INLINE flag float64_same( float64 a, float64 b )
427122b058aSross {
428122b058aSross 
429122b058aSross     return a == b;
430122b058aSross 
431122b058aSross }
432122b058aSross 
float64_isNaN(float64 a)433122b058aSross INLINE flag float64_isNaN( float64 a )
434122b058aSross {
435122b058aSross 
436122b058aSross     return LIT64( 0x7FF0000000000000 ) < ( a & LIT64( 0x7FFFFFFFFFFFFFFF ) );
437122b058aSross 
438122b058aSross }
439122b058aSross 
440122b058aSross #else
441122b058aSross 
float64_same(float64 a,float64 b)442122b058aSross INLINE flag float64_same( float64 a, float64 b )
443122b058aSross {
444122b058aSross 
445122b058aSross     return ( a.high == b.high ) && ( a.low == b.low );
446122b058aSross 
447122b058aSross }
448122b058aSross 
float64_isNaN(float64 a)449122b058aSross INLINE flag float64_isNaN( float64 a )
450122b058aSross {
451122b058aSross     bits32 absAHigh;
452122b058aSross 
453122b058aSross     absAHigh = a.high & 0x7FFFFFFF;
454122b058aSross     return
455122b058aSross         ( 0x7FF00000 < absAHigh ) || ( ( absAHigh == 0x7FF00000 ) && a.low );
456122b058aSross 
457122b058aSross }
458122b058aSross 
459122b058aSross #endif
460122b058aSross 
461122b058aSross #ifdef FLOATX80
462122b058aSross 
floatx80_same(floatx80 a,floatx80 b)463122b058aSross INLINE flag floatx80_same( floatx80 a, floatx80 b )
464122b058aSross {
465122b058aSross 
466122b058aSross     return ( a.high == b.high ) && ( a.low == b.low );
467122b058aSross 
468122b058aSross }
469122b058aSross 
floatx80_isNaN(floatx80 a)470122b058aSross INLINE flag floatx80_isNaN( floatx80 a )
471122b058aSross {
472122b058aSross 
473122b058aSross     return ( ( a.high & 0x7FFF ) == 0x7FFF ) && a.low;
474122b058aSross 
475122b058aSross }
476122b058aSross 
477122b058aSross #endif
478122b058aSross 
479122b058aSross #ifdef FLOAT128
480122b058aSross 
float128_same(float128 a,float128 b)481122b058aSross INLINE flag float128_same( float128 a, float128 b )
482122b058aSross {
483122b058aSross 
484122b058aSross     return ( a.high == b.high ) && ( a.low == b.low );
485122b058aSross 
486122b058aSross }
487122b058aSross 
float128_isNaN(float128 a)488122b058aSross INLINE flag float128_isNaN( float128 a )
489122b058aSross {
490122b058aSross     bits64 absAHigh;
491122b058aSross 
492122b058aSross     absAHigh = a.high & LIT64( 0x7FFFFFFFFFFFFFFF );
493122b058aSross     return
494122b058aSross            ( LIT64( 0x7FFF000000000000 ) < absAHigh )
495122b058aSross         || ( ( absAHigh == LIT64( 0x7FFF000000000000 ) ) && a.low );
496122b058aSross 
497122b058aSross }
498122b058aSross 
499122b058aSross #endif
500122b058aSross 
501122b058aSross void
test_a_int32_z_float32(float32 trueFunction (int32),float32 testFunction (int32))502122b058aSross  test_a_int32_z_float32(
503122b058aSross      float32 trueFunction( int32 ), float32 testFunction( int32 ) )
504122b058aSross {
505122b058aSross     int16 count;
506122b058aSross     float32 trueZ, testZ;
507122b058aSross     uint8 trueFlags, testFlags;
508122b058aSross 
509122b058aSross     errorCount = 0;
510122b058aSross     tenthousandsCount = 0;
511122b058aSross     count = 10000;
512122b058aSross     testCases_initSequence( testCases_sequence_a_int32 );
513122b058aSross     writeTestsTotal();
514122b058aSross     while ( ! testCases_done || forever ) {
515122b058aSross         testCases_next();
516122b058aSross         *trueFlagsPtr = 0;
517122b058aSross         trueZ = trueFunction( testCases_a_int32 );
518122b058aSross         trueFlags = *trueFlagsPtr;
519122b058aSross         (void) testFlagsFunctionPtr();
520122b058aSross         testZ = testFunction( testCases_a_int32 );
521122b058aSross         testFlags = testFlagsFunctionPtr();
522122b058aSross         --count;
523122b058aSross         if ( count == 0 ) {
524122b058aSross             checkEarlyExit();
525122b058aSross             count = 10000;
526122b058aSross         }
527122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
528122b058aSross             if (    ! checkNaNs
529122b058aSross                  && float32_isNaN( trueZ )
530122b058aSross                  && float32_isNaN( testZ )
531122b058aSross                  && ! float32_is_signaling_nan( testZ )
532122b058aSross                  && ( trueFlags == testFlags )
533122b058aSross                ) {
534122b058aSross                 /* no problem */
535122b058aSross             }
536122b058aSross             else {
537122b058aSross                 ++errorCount;
538122b058aSross                 writeErrorFound( 10000 - count );
539122b058aSross                 writeInput_a_int32();
540122b058aSross                 fputs( "  ", stdout );
541122b058aSross                 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
542122b058aSross                 fflush( stdout );
543122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
544122b058aSross             }
545122b058aSross         }
546122b058aSross     }
547122b058aSross  exit:
548122b058aSross     writeTestsPerformed( 10000 - count );
549122b058aSross 
550122b058aSross }
551122b058aSross 
552122b058aSross void
test_a_int32_z_float64(float64 trueFunction (int32),float64 testFunction (int32))553122b058aSross  test_a_int32_z_float64(
554122b058aSross      float64 trueFunction( int32 ), float64 testFunction( int32 ) )
555122b058aSross {
556122b058aSross     int16 count;
557122b058aSross     float64 trueZ, testZ;
558122b058aSross     uint8 trueFlags, testFlags;
559122b058aSross 
560122b058aSross     errorCount = 0;
561122b058aSross     tenthousandsCount = 0;
562122b058aSross     count = 10000;
563122b058aSross     testCases_initSequence( testCases_sequence_a_int32 );
564122b058aSross     writeTestsTotal();
565122b058aSross     while ( ! testCases_done || forever ) {
566122b058aSross         testCases_next();
567122b058aSross         *trueFlagsPtr = 0;
568122b058aSross         trueZ = trueFunction( testCases_a_int32 );
569122b058aSross         trueFlags = *trueFlagsPtr;
570122b058aSross         (void) testFlagsFunctionPtr();
571122b058aSross         testZ = testFunction( testCases_a_int32 );
572122b058aSross         testFlags = testFlagsFunctionPtr();
573122b058aSross         --count;
574122b058aSross         if ( count == 0 ) {
575122b058aSross             checkEarlyExit();
576122b058aSross             count = 10000;
577122b058aSross         }
578122b058aSross         if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
579122b058aSross             if (    ! checkNaNs
580122b058aSross                  && float64_isNaN( trueZ )
581122b058aSross                  && float64_isNaN( testZ )
582122b058aSross                  && ! float64_is_signaling_nan( testZ )
583122b058aSross                  && ( trueFlags == testFlags )
584122b058aSross                ) {
585122b058aSross                 /* no problem */
586122b058aSross             }
587122b058aSross             else {
588122b058aSross                 ++errorCount;
589122b058aSross                 writeErrorFound( 10000 - count );
590122b058aSross                 writeInput_a_int32();
591122b058aSross                 fputs( "  ", stdout );
592122b058aSross                 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
593122b058aSross                 fflush( stdout );
594122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
595122b058aSross             }
596122b058aSross         }
597122b058aSross     }
598122b058aSross  exit:
599122b058aSross     writeTestsPerformed( 10000 - count );
600122b058aSross 
601122b058aSross }
602122b058aSross 
603122b058aSross #ifdef FLOATX80
604122b058aSross 
605122b058aSross void
test_a_int32_z_floatx80(floatx80 trueFunction (int32),floatx80 testFunction (int32))606122b058aSross  test_a_int32_z_floatx80(
607122b058aSross      floatx80 trueFunction( int32 ), floatx80 testFunction( int32 ) )
608122b058aSross {
609122b058aSross     int16 count;
610122b058aSross     floatx80 trueZ, testZ;
611122b058aSross     uint8 trueFlags, testFlags;
612122b058aSross 
613122b058aSross     errorCount = 0;
614122b058aSross     tenthousandsCount = 0;
615122b058aSross     count = 10000;
616122b058aSross     testCases_initSequence( testCases_sequence_a_int32 );
617122b058aSross     writeTestsTotal();
618122b058aSross     while ( ! testCases_done || forever ) {
619122b058aSross         testCases_next();
620122b058aSross         *trueFlagsPtr = 0;
621122b058aSross         trueZ = trueFunction( testCases_a_int32 );
622122b058aSross         trueFlags = *trueFlagsPtr;
623122b058aSross         (void) testFlagsFunctionPtr();
624122b058aSross         testZ = testFunction( testCases_a_int32 );
625122b058aSross         testFlags = testFlagsFunctionPtr();
626122b058aSross         --count;
627122b058aSross         if ( count == 0 ) {
628122b058aSross             checkEarlyExit();
629122b058aSross             count = 10000;
630122b058aSross         }
631122b058aSross         if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
632122b058aSross             if (    ! checkNaNs
633122b058aSross                  && floatx80_isNaN( trueZ )
634122b058aSross                  && floatx80_isNaN( testZ )
635122b058aSross                  && ! floatx80_is_signaling_nan( testZ )
636122b058aSross                  && ( trueFlags == testFlags )
637122b058aSross                ) {
638122b058aSross                 /* no problem */
639122b058aSross             }
640122b058aSross             else {
641122b058aSross                 ++errorCount;
642122b058aSross                 writeErrorFound( 10000 - count );
643122b058aSross                 writeInput_a_int32();
644122b058aSross                 fputs( "  ", stdout );
645122b058aSross                 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
646122b058aSross                 fflush( stdout );
647122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
648122b058aSross             }
649122b058aSross         }
650122b058aSross     }
651122b058aSross  exit:
652122b058aSross     writeTestsPerformed( 10000 - count );
653122b058aSross 
654122b058aSross }
655122b058aSross 
656122b058aSross #endif
657122b058aSross 
658122b058aSross #ifdef FLOAT128
659122b058aSross 
660122b058aSross void
test_a_int32_z_float128(float128 trueFunction (int32),float128 testFunction (int32))661122b058aSross  test_a_int32_z_float128(
662122b058aSross      float128 trueFunction( int32 ), float128 testFunction( int32 ) )
663122b058aSross {
664122b058aSross     int16 count;
665122b058aSross     float128 trueZ, testZ;
666122b058aSross     uint8 trueFlags, testFlags;
667122b058aSross 
668122b058aSross     errorCount = 0;
669122b058aSross     tenthousandsCount = 0;
670122b058aSross     count = 10000;
671122b058aSross     testCases_initSequence( testCases_sequence_a_int32 );
672122b058aSross     writeTestsTotal();
673122b058aSross     while ( ! testCases_done || forever ) {
674122b058aSross         testCases_next();
675122b058aSross         *trueFlagsPtr = 0;
676122b058aSross         trueZ = trueFunction( testCases_a_int32 );
677122b058aSross         trueFlags = *trueFlagsPtr;
678122b058aSross         (void) testFlagsFunctionPtr();
679122b058aSross         testZ = testFunction( testCases_a_int32 );
680122b058aSross         testFlags = testFlagsFunctionPtr();
681122b058aSross         --count;
682122b058aSross         if ( count == 0 ) {
683122b058aSross             checkEarlyExit();
684122b058aSross             count = 10000;
685122b058aSross         }
686122b058aSross         if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
687122b058aSross             if (    ! checkNaNs
688122b058aSross                  && float128_isNaN( trueZ )
689122b058aSross                  && float128_isNaN( testZ )
690122b058aSross                  && ! float128_is_signaling_nan( testZ )
691122b058aSross                  && ( trueFlags == testFlags )
692122b058aSross                ) {
693122b058aSross                 /* no problem */
694122b058aSross             }
695122b058aSross             else {
696122b058aSross                 ++errorCount;
697122b058aSross                 writeErrorFound( 10000 - count );
698122b058aSross                 writeInput_a_int32();
699122b058aSross                 fputs( "\n\t", stdout );
700122b058aSross                 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
701122b058aSross                 fflush( stdout );
702122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
703122b058aSross             }
704122b058aSross         }
705122b058aSross     }
706122b058aSross  exit:
707122b058aSross     writeTestsPerformed( 10000 - count );
708122b058aSross 
709122b058aSross }
710122b058aSross 
711122b058aSross #endif
712122b058aSross 
713122b058aSross #ifdef BITS64
714122b058aSross 
715122b058aSross void
test_a_int64_z_float32(float32 trueFunction (int64),float32 testFunction (int64))716122b058aSross  test_a_int64_z_float32(
717122b058aSross      float32 trueFunction( int64 ), float32 testFunction( int64 ) )
718122b058aSross {
719122b058aSross     int16 count;
720122b058aSross     float32 trueZ, testZ;
721122b058aSross     uint8 trueFlags, testFlags;
722122b058aSross 
723122b058aSross     errorCount = 0;
724122b058aSross     tenthousandsCount = 0;
725122b058aSross     count = 10000;
726122b058aSross     testCases_initSequence( testCases_sequence_a_int64 );
727122b058aSross     writeTestsTotal();
728122b058aSross     while ( ! testCases_done || forever ) {
729122b058aSross         testCases_next();
730122b058aSross         *trueFlagsPtr = 0;
731122b058aSross         trueZ = trueFunction( testCases_a_int64 );
732122b058aSross         trueFlags = *trueFlagsPtr;
733122b058aSross         (void) testFlagsFunctionPtr();
734122b058aSross         testZ = testFunction( testCases_a_int64 );
735122b058aSross         testFlags = testFlagsFunctionPtr();
736122b058aSross         --count;
737122b058aSross         if ( count == 0 ) {
738122b058aSross             checkEarlyExit();
739122b058aSross             count = 10000;
740122b058aSross         }
741122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
742122b058aSross             if (    ! checkNaNs
743122b058aSross                  && float32_isNaN( trueZ )
744122b058aSross                  && float32_isNaN( testZ )
745122b058aSross                  && ! float32_is_signaling_nan( testZ )
746122b058aSross                  && ( trueFlags == testFlags )
747122b058aSross                ) {
748122b058aSross                 /* no problem */
749122b058aSross             }
750122b058aSross             else {
751122b058aSross                 ++errorCount;
752122b058aSross                 writeErrorFound( 10000 - count );
753122b058aSross                 writeInput_a_int64();
754122b058aSross                 fputs( "  ", stdout );
755122b058aSross                 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
756122b058aSross                 fflush( stdout );
757122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
758122b058aSross             }
759122b058aSross         }
760122b058aSross     }
761122b058aSross  exit:
762122b058aSross     writeTestsPerformed( 10000 - count );
763122b058aSross 
764122b058aSross }
765122b058aSross 
766122b058aSross void
test_a_int64_z_float64(float64 trueFunction (int64),float64 testFunction (int64))767122b058aSross  test_a_int64_z_float64(
768122b058aSross      float64 trueFunction( int64 ), float64 testFunction( int64 ) )
769122b058aSross {
770122b058aSross     int16 count;
771122b058aSross     float64 trueZ, testZ;
772122b058aSross     uint8 trueFlags, testFlags;
773122b058aSross 
774122b058aSross     errorCount = 0;
775122b058aSross     tenthousandsCount = 0;
776122b058aSross     count = 10000;
777122b058aSross     testCases_initSequence( testCases_sequence_a_int64 );
778122b058aSross     writeTestsTotal();
779122b058aSross     while ( ! testCases_done || forever ) {
780122b058aSross         testCases_next();
781122b058aSross         *trueFlagsPtr = 0;
782122b058aSross         trueZ = trueFunction( testCases_a_int64 );
783122b058aSross         trueFlags = *trueFlagsPtr;
784122b058aSross         (void) testFlagsFunctionPtr();
785122b058aSross         testZ = testFunction( testCases_a_int64 );
786122b058aSross         testFlags = testFlagsFunctionPtr();
787122b058aSross         --count;
788122b058aSross         if ( count == 0 ) {
789122b058aSross             checkEarlyExit();
790122b058aSross             count = 10000;
791122b058aSross         }
792122b058aSross         if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
793122b058aSross             if (    ! checkNaNs
794122b058aSross                  && float64_isNaN( trueZ )
795122b058aSross                  && float64_isNaN( testZ )
796122b058aSross                  && ! float64_is_signaling_nan( testZ )
797122b058aSross                  && ( trueFlags == testFlags )
798122b058aSross                ) {
799122b058aSross                 /* no problem */
800122b058aSross             }
801122b058aSross             else {
802122b058aSross                 ++errorCount;
803122b058aSross                 writeErrorFound( 10000 - count );
804122b058aSross                 writeInput_a_int64();
805122b058aSross                 fputs( "  ", stdout );
806122b058aSross                 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
807122b058aSross                 fflush( stdout );
808122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
809122b058aSross             }
810122b058aSross         }
811122b058aSross     }
812122b058aSross  exit:
813122b058aSross     writeTestsPerformed( 10000 - count );
814122b058aSross 
815122b058aSross }
816122b058aSross 
817122b058aSross #ifdef FLOATX80
818122b058aSross 
819122b058aSross void
test_a_int64_z_floatx80(floatx80 trueFunction (int64),floatx80 testFunction (int64))820122b058aSross  test_a_int64_z_floatx80(
821122b058aSross      floatx80 trueFunction( int64 ), floatx80 testFunction( int64 ) )
822122b058aSross {
823122b058aSross     int16 count;
824122b058aSross     floatx80 trueZ, testZ;
825122b058aSross     uint8 trueFlags, testFlags;
826122b058aSross 
827122b058aSross     errorCount = 0;
828122b058aSross     tenthousandsCount = 0;
829122b058aSross     count = 10000;
830122b058aSross     testCases_initSequence( testCases_sequence_a_int64 );
831122b058aSross     writeTestsTotal();
832122b058aSross     while ( ! testCases_done || forever ) {
833122b058aSross         testCases_next();
834122b058aSross         *trueFlagsPtr = 0;
835122b058aSross         trueZ = trueFunction( testCases_a_int64 );
836122b058aSross         trueFlags = *trueFlagsPtr;
837122b058aSross         (void) testFlagsFunctionPtr();
838122b058aSross         testZ = testFunction( testCases_a_int64 );
839122b058aSross         testFlags = testFlagsFunctionPtr();
840122b058aSross         --count;
841122b058aSross         if ( count == 0 ) {
842122b058aSross             checkEarlyExit();
843122b058aSross             count = 10000;
844122b058aSross         }
845122b058aSross         if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
846122b058aSross             if (    ! checkNaNs
847122b058aSross                  && floatx80_isNaN( trueZ )
848122b058aSross                  && floatx80_isNaN( testZ )
849122b058aSross                  && ! floatx80_is_signaling_nan( testZ )
850122b058aSross                  && ( trueFlags == testFlags )
851122b058aSross                ) {
852122b058aSross                 /* no problem */
853122b058aSross             }
854122b058aSross             else {
855122b058aSross                 ++errorCount;
856122b058aSross                 writeErrorFound( 10000 - count );
857122b058aSross                 writeInput_a_int64();
858122b058aSross                 fputs( "  ", stdout );
859122b058aSross                 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
860122b058aSross                 fflush( stdout );
861122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
862122b058aSross             }
863122b058aSross         }
864122b058aSross     }
865122b058aSross  exit:
866122b058aSross     writeTestsPerformed( 10000 - count );
867122b058aSross 
868122b058aSross }
869122b058aSross 
870122b058aSross #endif
871122b058aSross 
872122b058aSross #ifdef FLOAT128
873122b058aSross 
874122b058aSross void
test_a_int64_z_float128(float128 trueFunction (int64),float128 testFunction (int64))875122b058aSross  test_a_int64_z_float128(
876122b058aSross      float128 trueFunction( int64 ), float128 testFunction( int64 ) )
877122b058aSross {
878122b058aSross     int16 count;
879122b058aSross     float128 trueZ, testZ;
880122b058aSross     uint8 trueFlags, testFlags;
881122b058aSross 
882122b058aSross     errorCount = 0;
883122b058aSross     tenthousandsCount = 0;
884122b058aSross     count = 10000;
885122b058aSross     testCases_initSequence( testCases_sequence_a_int64 );
886122b058aSross     writeTestsTotal();
887122b058aSross     while ( ! testCases_done || forever ) {
888122b058aSross         testCases_next();
889122b058aSross         *trueFlagsPtr = 0;
890122b058aSross         trueZ = trueFunction( testCases_a_int64 );
891122b058aSross         trueFlags = *trueFlagsPtr;
892122b058aSross         (void) testFlagsFunctionPtr();
893122b058aSross         testZ = testFunction( testCases_a_int64 );
894122b058aSross         testFlags = testFlagsFunctionPtr();
895122b058aSross         --count;
896122b058aSross         if ( count == 0 ) {
897122b058aSross             checkEarlyExit();
898122b058aSross             count = 10000;
899122b058aSross         }
900122b058aSross         if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
901122b058aSross             if (    ! checkNaNs
902122b058aSross                  && float128_isNaN( trueZ )
903122b058aSross                  && float128_isNaN( testZ )
904122b058aSross                  && ! float128_is_signaling_nan( testZ )
905122b058aSross                  && ( trueFlags == testFlags )
906122b058aSross                ) {
907122b058aSross                 /* no problem */
908122b058aSross             }
909122b058aSross             else {
910122b058aSross                 ++errorCount;
911122b058aSross                 writeErrorFound( 10000 - count );
912122b058aSross                 writeInput_a_int64();
913122b058aSross                 fputs( "\n\t", stdout );
914122b058aSross                 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
915122b058aSross                 fflush( stdout );
916122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
917122b058aSross             }
918122b058aSross         }
919122b058aSross     }
920122b058aSross  exit:
921122b058aSross     writeTestsPerformed( 10000 - count );
922122b058aSross 
923122b058aSross }
924122b058aSross 
925122b058aSross #endif
926122b058aSross 
927122b058aSross #endif
928122b058aSross 
929122b058aSross void
test_a_float32_z_int32(int32 trueFunction (float32),int32 testFunction (float32))930122b058aSross  test_a_float32_z_int32(
931122b058aSross      int32 trueFunction( float32 ), int32 testFunction( float32 ) )
932122b058aSross {
933122b058aSross     int16 count;
934122b058aSross     int32 trueZ, testZ;
935122b058aSross     uint8 trueFlags, testFlags;
936122b058aSross 
937122b058aSross     errorCount = 0;
938122b058aSross     tenthousandsCount = 0;
939122b058aSross     count = 10000;
940122b058aSross     testCases_initSequence( testCases_sequence_a_float32 );
941122b058aSross     writeTestsTotal();
942122b058aSross     while ( ! testCases_done || forever ) {
943122b058aSross         testCases_next();
944122b058aSross         *trueFlagsPtr = 0;
945122b058aSross         trueZ = trueFunction( testCases_a_float32 );
946122b058aSross         trueFlags = *trueFlagsPtr;
947122b058aSross         (void) testFlagsFunctionPtr();
948122b058aSross         testZ = testFunction( testCases_a_float32 );
949122b058aSross         testFlags = testFlagsFunctionPtr();
950122b058aSross         --count;
951122b058aSross         if ( count == 0 ) {
952122b058aSross             checkEarlyExit();
953122b058aSross             count = 10000;
954122b058aSross         }
955122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
956122b058aSross             if (    ! checkNaNs
957122b058aSross                  && float32_is_signaling_nan( testCases_a_float32 ) ) {
958122b058aSross                 trueFlags |= float_flag_invalid;
959122b058aSross             }
960122b058aSross             if (    ( trueZ == 0x7FFFFFFF )
961122b058aSross                  && (    ( testZ == 0x7FFFFFFF )
962122b058aSross                       || ( testZ == (sbits32) 0x80000000 ) )
963122b058aSross                  && ( trueFlags == float_flag_invalid )
964122b058aSross                  && ( testFlags == float_flag_invalid )
965122b058aSross                ) {
966122b058aSross                 /* no problem */
967122b058aSross             }
968122b058aSross             else {
969122b058aSross                 ++errorCount;
970122b058aSross                 writeErrorFound( 10000 - count );
971122b058aSross                 writeInput_a_float32();
972122b058aSross                 fputs( "  ", stdout );
973122b058aSross                 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags );
974122b058aSross                 fflush( stdout );
975122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
976122b058aSross             }
977122b058aSross         }
978122b058aSross     }
979122b058aSross  exit:
980122b058aSross     writeTestsPerformed( 10000 - count );
981122b058aSross 
982122b058aSross }
983122b058aSross 
984122b058aSross #ifdef BITS64
985122b058aSross 
986122b058aSross void
test_a_float32_z_int64(int64 trueFunction (float32),int64 testFunction (float32))987122b058aSross  test_a_float32_z_int64(
988122b058aSross      int64 trueFunction( float32 ), int64 testFunction( float32 ) )
989122b058aSross {
990122b058aSross     int16 count;
991122b058aSross     int64 trueZ, testZ;
992122b058aSross     uint8 trueFlags, testFlags;
993122b058aSross 
994122b058aSross     errorCount = 0;
995122b058aSross     tenthousandsCount = 0;
996122b058aSross     count = 10000;
997122b058aSross     testCases_initSequence( testCases_sequence_a_float32 );
998122b058aSross     writeTestsTotal();
999122b058aSross     while ( ! testCases_done || forever ) {
1000122b058aSross         testCases_next();
1001122b058aSross         *trueFlagsPtr = 0;
1002122b058aSross         trueZ = trueFunction( testCases_a_float32 );
1003122b058aSross         trueFlags = *trueFlagsPtr;
1004122b058aSross         (void) testFlagsFunctionPtr();
1005122b058aSross         testZ = testFunction( testCases_a_float32 );
1006122b058aSross         testFlags = testFlagsFunctionPtr();
1007122b058aSross         --count;
1008122b058aSross         if ( count == 0 ) {
1009122b058aSross             checkEarlyExit();
1010122b058aSross             count = 10000;
1011122b058aSross         }
1012122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1013122b058aSross             if (    ! checkNaNs
1014122b058aSross                  && float32_is_signaling_nan( testCases_a_float32 ) ) {
1015122b058aSross                 trueFlags |= float_flag_invalid;
1016122b058aSross             }
1017122b058aSross             if (    ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1018122b058aSross                  && (    ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1019122b058aSross                       || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) )
1020122b058aSross                  && ( trueFlags == float_flag_invalid )
1021122b058aSross                  && ( testFlags == float_flag_invalid )
1022122b058aSross                ) {
1023122b058aSross                 /* no problem */
1024122b058aSross             }
1025122b058aSross             else {
1026122b058aSross                 ++errorCount;
1027122b058aSross                 writeErrorFound( 10000 - count );
1028122b058aSross                 writeInput_a_float32();
1029122b058aSross                 fputs( "  ", stdout );
1030122b058aSross                 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags );
1031122b058aSross                 fflush( stdout );
1032122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1033122b058aSross             }
1034122b058aSross         }
1035122b058aSross     }
1036122b058aSross  exit:
1037122b058aSross     writeTestsPerformed( 10000 - count );
1038122b058aSross 
1039122b058aSross }
1040122b058aSross 
1041122b058aSross #endif
1042122b058aSross 
1043122b058aSross void
test_a_float32_z_float64(float64 trueFunction (float32),float64 testFunction (float32))1044122b058aSross  test_a_float32_z_float64(
1045122b058aSross      float64 trueFunction( float32 ), float64 testFunction( float32 ) )
1046122b058aSross {
1047122b058aSross     int16 count;
1048122b058aSross     float64 trueZ, testZ;
1049122b058aSross     uint8 trueFlags, testFlags;
1050122b058aSross 
1051122b058aSross     errorCount = 0;
1052122b058aSross     tenthousandsCount = 0;
1053122b058aSross     count = 10000;
1054122b058aSross     testCases_initSequence( testCases_sequence_a_float32 );
1055122b058aSross     writeTestsTotal();
1056122b058aSross     while ( ! testCases_done || forever ) {
1057122b058aSross         testCases_next();
1058122b058aSross         *trueFlagsPtr = 0;
1059122b058aSross         trueZ = trueFunction( testCases_a_float32 );
1060122b058aSross         trueFlags = *trueFlagsPtr;
1061122b058aSross         (void) testFlagsFunctionPtr();
1062122b058aSross         testZ = testFunction( testCases_a_float32 );
1063122b058aSross         testFlags = testFlagsFunctionPtr();
1064122b058aSross         --count;
1065122b058aSross         if ( count == 0 ) {
1066122b058aSross             checkEarlyExit();
1067122b058aSross             count = 10000;
1068122b058aSross         }
1069122b058aSross         if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1070122b058aSross             if (    ! checkNaNs
1071122b058aSross                  && float32_is_signaling_nan( testCases_a_float32 ) ) {
1072122b058aSross                 trueFlags |= float_flag_invalid;
1073122b058aSross             }
1074122b058aSross             if (    ! checkNaNs
1075122b058aSross                  && float64_isNaN( trueZ )
1076122b058aSross                  && float64_isNaN( testZ )
1077122b058aSross                  && ! float64_is_signaling_nan( testZ )
1078122b058aSross                  && ( trueFlags == testFlags )
1079122b058aSross                ) {
1080122b058aSross                 /* no problem */
1081122b058aSross             }
1082122b058aSross             else {
1083122b058aSross                 ++errorCount;
1084122b058aSross                 writeErrorFound( 10000 - count );
1085122b058aSross                 writeInput_a_float32();
1086122b058aSross                 fputs( "  ", stdout );
1087122b058aSross                 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
1088122b058aSross                 fflush( stdout );
1089122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1090122b058aSross             }
1091122b058aSross         }
1092122b058aSross     }
1093122b058aSross  exit:
1094122b058aSross     writeTestsPerformed( 10000 - count );
1095122b058aSross 
1096122b058aSross }
1097122b058aSross 
1098122b058aSross #ifdef FLOATX80
1099122b058aSross 
1100122b058aSross void
test_a_float32_z_floatx80(floatx80 trueFunction (float32),floatx80 testFunction (float32))1101122b058aSross  test_a_float32_z_floatx80(
1102122b058aSross      floatx80 trueFunction( float32 ), floatx80 testFunction( float32 ) )
1103122b058aSross {
1104122b058aSross     int16 count;
1105122b058aSross     floatx80 trueZ, testZ;
1106122b058aSross     uint8 trueFlags, testFlags;
1107122b058aSross 
1108122b058aSross     errorCount = 0;
1109122b058aSross     tenthousandsCount = 0;
1110122b058aSross     count = 10000;
1111122b058aSross     testCases_initSequence( testCases_sequence_a_float32 );
1112122b058aSross     writeTestsTotal();
1113122b058aSross     while ( ! testCases_done || forever ) {
1114122b058aSross         testCases_next();
1115122b058aSross         *trueFlagsPtr = 0;
1116122b058aSross         trueZ = trueFunction( testCases_a_float32 );
1117122b058aSross         trueFlags = *trueFlagsPtr;
1118122b058aSross         (void) testFlagsFunctionPtr();
1119122b058aSross         testZ = testFunction( testCases_a_float32 );
1120122b058aSross         testFlags = testFlagsFunctionPtr();
1121122b058aSross         --count;
1122122b058aSross         if ( count == 0 ) {
1123122b058aSross             checkEarlyExit();
1124122b058aSross             count = 10000;
1125122b058aSross         }
1126122b058aSross         if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1127122b058aSross             if (    ! checkNaNs
1128122b058aSross                  && float32_is_signaling_nan( testCases_a_float32 ) ) {
1129122b058aSross                 trueFlags |= float_flag_invalid;
1130122b058aSross             }
1131122b058aSross             if (    ! checkNaNs
1132122b058aSross                  && floatx80_isNaN( trueZ )
1133122b058aSross                  && floatx80_isNaN( testZ )
1134122b058aSross                  && ! floatx80_is_signaling_nan( testZ )
1135122b058aSross                  && ( trueFlags == testFlags )
1136122b058aSross                ) {
1137122b058aSross                 /* no problem */
1138122b058aSross             }
1139122b058aSross             else {
1140122b058aSross                 ++errorCount;
1141122b058aSross                 writeErrorFound( 10000 - count );
1142122b058aSross                 writeInput_a_float32();
1143122b058aSross                 fputs( "\n\t", stdout );
1144122b058aSross                 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
1145122b058aSross                 fflush( stdout );
1146122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1147122b058aSross             }
1148122b058aSross         }
1149122b058aSross     }
1150122b058aSross  exit:
1151122b058aSross     writeTestsPerformed( 10000 - count );
1152122b058aSross 
1153122b058aSross }
1154122b058aSross 
1155122b058aSross #endif
1156122b058aSross 
1157122b058aSross #ifdef FLOAT128
1158122b058aSross 
1159122b058aSross void
test_a_float32_z_float128(float128 trueFunction (float32),float128 testFunction (float32))1160122b058aSross  test_a_float32_z_float128(
1161122b058aSross      float128 trueFunction( float32 ), float128 testFunction( float32 ) )
1162122b058aSross {
1163122b058aSross     int16 count;
1164122b058aSross     float128 trueZ, testZ;
1165122b058aSross     uint8 trueFlags, testFlags;
1166122b058aSross 
1167122b058aSross     errorCount = 0;
1168122b058aSross     tenthousandsCount = 0;
1169122b058aSross     count = 10000;
1170122b058aSross     testCases_initSequence( testCases_sequence_a_float32 );
1171122b058aSross     writeTestsTotal();
1172122b058aSross     while ( ! testCases_done || forever ) {
1173122b058aSross         testCases_next();
1174122b058aSross         *trueFlagsPtr = 0;
1175122b058aSross         trueZ = trueFunction( testCases_a_float32 );
1176122b058aSross         trueFlags = *trueFlagsPtr;
1177122b058aSross         (void) testFlagsFunctionPtr();
1178122b058aSross         testZ = testFunction( testCases_a_float32 );
1179122b058aSross         testFlags = testFlagsFunctionPtr();
1180122b058aSross         --count;
1181122b058aSross         if ( count == 0 ) {
1182122b058aSross             checkEarlyExit();
1183122b058aSross             count = 10000;
1184122b058aSross         }
1185122b058aSross         if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1186122b058aSross             if (    ! checkNaNs
1187122b058aSross                  && float32_is_signaling_nan( testCases_a_float32 ) ) {
1188122b058aSross                 trueFlags |= float_flag_invalid;
1189122b058aSross             }
1190122b058aSross             if (    ! checkNaNs
1191122b058aSross                  && float128_isNaN( trueZ )
1192122b058aSross                  && float128_isNaN( testZ )
1193122b058aSross                  && ! float128_is_signaling_nan( testZ )
1194122b058aSross                  && ( trueFlags == testFlags )
1195122b058aSross                ) {
1196122b058aSross                 /* no problem */
1197122b058aSross             }
1198122b058aSross             else {
1199122b058aSross                 ++errorCount;
1200122b058aSross                 writeErrorFound( 10000 - count );
1201122b058aSross                 writeInput_a_float32();
1202122b058aSross                 fputs( "\n\t", stdout );
1203122b058aSross                 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
1204122b058aSross                 fflush( stdout );
1205122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1206122b058aSross             }
1207122b058aSross         }
1208122b058aSross     }
1209122b058aSross  exit:
1210122b058aSross     writeTestsPerformed( 10000 - count );
1211122b058aSross 
1212122b058aSross }
1213122b058aSross 
1214122b058aSross #endif
1215122b058aSross 
1216122b058aSross void
test_az_float32(float32 trueFunction (float32),float32 testFunction (float32))1217122b058aSross  test_az_float32(
1218122b058aSross      float32 trueFunction( float32 ), float32 testFunction( float32 ) )
1219122b058aSross {
1220122b058aSross     int16 count;
1221122b058aSross     float32 trueZ, testZ;
1222122b058aSross     uint8 trueFlags, testFlags;
1223122b058aSross 
1224122b058aSross     errorCount = 0;
1225122b058aSross     tenthousandsCount = 0;
1226122b058aSross     count = 10000;
1227122b058aSross     testCases_initSequence( testCases_sequence_a_float32 );
1228122b058aSross     writeTestsTotal();
1229122b058aSross     while ( ! testCases_done || forever ) {
1230122b058aSross         testCases_next();
1231122b058aSross         *trueFlagsPtr = 0;
1232122b058aSross         trueZ = trueFunction( testCases_a_float32 );
1233122b058aSross         trueFlags = *trueFlagsPtr;
1234122b058aSross         (void) testFlagsFunctionPtr();
1235122b058aSross         testZ = testFunction( testCases_a_float32 );
1236122b058aSross         testFlags = testFlagsFunctionPtr();
1237122b058aSross         --count;
1238122b058aSross         if ( count == 0 ) {
1239122b058aSross             checkEarlyExit();
1240122b058aSross             count = 10000;
1241122b058aSross         }
1242122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1243122b058aSross             if (    ! checkNaNs
1244122b058aSross                  && float32_is_signaling_nan( testCases_a_float32 ) ) {
1245122b058aSross                 trueFlags |= float_flag_invalid;
1246122b058aSross             }
1247122b058aSross             if (    ! checkNaNs
1248122b058aSross                  && float32_isNaN( trueZ )
1249122b058aSross                  && float32_isNaN( testZ )
1250122b058aSross                  && ! float32_is_signaling_nan( testZ )
1251122b058aSross                  && ( trueFlags == testFlags )
1252122b058aSross                ) {
1253122b058aSross                 /* no problem */
1254122b058aSross             }
1255122b058aSross             else {
1256122b058aSross                 ++errorCount;
1257122b058aSross                 writeErrorFound( 10000 - count );
1258122b058aSross                 writeInput_a_float32();
1259122b058aSross                 fputs( "  ", stdout );
1260122b058aSross                 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
1261122b058aSross                 fflush( stdout );
1262122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1263122b058aSross             }
1264122b058aSross         }
1265122b058aSross     }
1266122b058aSross  exit:
1267122b058aSross     writeTestsPerformed( 10000 - count );
1268122b058aSross 
1269122b058aSross }
1270122b058aSross 
1271122b058aSross void
test_ab_float32_z_flag(flag trueFunction (float32,float32),flag testFunction (float32,float32))1272122b058aSross  test_ab_float32_z_flag(
1273122b058aSross      flag trueFunction( float32, float32 ),
1274122b058aSross      flag testFunction( float32, float32 )
1275122b058aSross  )
1276122b058aSross {
1277122b058aSross     int16 count;
1278122b058aSross     flag trueZ, testZ;
1279122b058aSross     uint8 trueFlags, testFlags;
1280122b058aSross 
1281122b058aSross     errorCount = 0;
1282122b058aSross     tenthousandsCount = 0;
1283122b058aSross     count = 10000;
1284122b058aSross     testCases_initSequence( testCases_sequence_ab_float32 );
1285122b058aSross     writeTestsTotal();
1286122b058aSross     while ( ! testCases_done || forever ) {
1287122b058aSross         testCases_next();
1288122b058aSross         *trueFlagsPtr = 0;
1289122b058aSross         trueZ = trueFunction( testCases_a_float32, testCases_b_float32 );
1290122b058aSross         trueFlags = *trueFlagsPtr;
1291122b058aSross         (void) testFlagsFunctionPtr();
1292122b058aSross         testZ = testFunction( testCases_a_float32, testCases_b_float32 );
1293122b058aSross         testFlags = testFlagsFunctionPtr();
1294122b058aSross         --count;
1295122b058aSross         if ( count == 0 ) {
1296122b058aSross             checkEarlyExit();
1297122b058aSross             count = 10000;
1298122b058aSross         }
1299122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1300122b058aSross             if (    ! checkNaNs
1301122b058aSross                  && (    float32_is_signaling_nan( testCases_a_float32 )
1302122b058aSross                       || float32_is_signaling_nan( testCases_b_float32 ) )
1303122b058aSross                ) {
1304122b058aSross                 trueFlags |= float_flag_invalid;
1305122b058aSross             }
1306122b058aSross             if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1307122b058aSross                 ++errorCount;
1308122b058aSross                 writeErrorFound( 10000 - count );
1309122b058aSross                 writeInputs_ab_float32();
1310122b058aSross                 fputs( "  ", stdout );
1311122b058aSross                 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags );
1312122b058aSross                 fflush( stdout );
1313122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1314122b058aSross             }
1315122b058aSross         }
1316122b058aSross     }
1317122b058aSross  exit:
1318122b058aSross     writeTestsPerformed( 10000 - count );
1319122b058aSross     return;
1320122b058aSross 
1321122b058aSross }
1322122b058aSross 
1323122b058aSross void
test_abz_float32(float32 trueFunction (float32,float32),float32 testFunction (float32,float32))1324122b058aSross  test_abz_float32(
1325122b058aSross      float32 trueFunction( float32, float32 ),
1326122b058aSross      float32 testFunction( float32, float32 )
1327122b058aSross  )
1328122b058aSross {
1329122b058aSross     int16 count;
1330122b058aSross     float32 trueZ, testZ;
1331122b058aSross     uint8 trueFlags, testFlags;
1332122b058aSross 
1333122b058aSross     errorCount = 0;
1334122b058aSross     tenthousandsCount = 0;
1335122b058aSross     count = 10000;
1336122b058aSross     testCases_initSequence( testCases_sequence_ab_float32 );
1337122b058aSross     writeTestsTotal();
1338122b058aSross     while ( ! testCases_done || forever ) {
1339122b058aSross         testCases_next();
1340122b058aSross         *trueFlagsPtr = 0;
1341122b058aSross         trueZ = trueFunction( testCases_a_float32, testCases_b_float32 );
1342122b058aSross         trueFlags = *trueFlagsPtr;
1343122b058aSross         (void) testFlagsFunctionPtr();
1344122b058aSross         testZ = testFunction( testCases_a_float32, testCases_b_float32 );
1345122b058aSross         testFlags = testFlagsFunctionPtr();
1346122b058aSross         --count;
1347122b058aSross         if ( count == 0 ) {
1348122b058aSross             checkEarlyExit();
1349122b058aSross             count = 10000;
1350122b058aSross         }
1351122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1352122b058aSross             if (    ! checkNaNs
1353122b058aSross                  && (    float32_is_signaling_nan( testCases_a_float32 )
1354122b058aSross                       || float32_is_signaling_nan( testCases_b_float32 ) )
1355122b058aSross                ) {
1356122b058aSross                 trueFlags |= float_flag_invalid;
1357122b058aSross             }
1358122b058aSross             if (    ! checkNaNs
1359122b058aSross                  && float32_isNaN( trueZ )
1360122b058aSross                  && float32_isNaN( testZ )
1361122b058aSross                  && ! float32_is_signaling_nan( testZ )
1362122b058aSross                  && ( trueFlags == testFlags )
1363122b058aSross                ) {
1364122b058aSross                 /* no problem */
1365122b058aSross             }
1366122b058aSross             else {
1367122b058aSross                 ++errorCount;
1368122b058aSross                 writeErrorFound( 10000 - count );
1369122b058aSross                 writeInputs_ab_float32();
1370122b058aSross                 fputs( "  ", stdout );
1371122b058aSross                 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
1372122b058aSross                 fflush( stdout );
1373122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1374122b058aSross             }
1375122b058aSross         }
1376122b058aSross     }
1377122b058aSross  exit:
1378122b058aSross     writeTestsPerformed( 10000 - count );
1379122b058aSross     return;
1380122b058aSross 
1381122b058aSross }
1382122b058aSross 
1383122b058aSross void
test_a_float64_z_int32(int32 trueFunction (float64),int32 testFunction (float64))1384122b058aSross  test_a_float64_z_int32(
1385122b058aSross      int32 trueFunction( float64 ), int32 testFunction( float64 ) )
1386122b058aSross {
1387122b058aSross     int16 count;
1388122b058aSross     int32 trueZ, testZ;
1389122b058aSross     uint8 trueFlags, testFlags;
1390122b058aSross 
1391122b058aSross     errorCount = 0;
1392122b058aSross     tenthousandsCount = 0;
1393122b058aSross     count = 10000;
1394122b058aSross     testCases_initSequence( testCases_sequence_a_float64 );
1395122b058aSross     writeTestsTotal();
1396122b058aSross     while ( ! testCases_done || forever ) {
1397122b058aSross         testCases_next();
1398122b058aSross         *trueFlagsPtr = 0;
1399122b058aSross         trueZ = trueFunction( testCases_a_float64 );
1400122b058aSross         trueFlags = *trueFlagsPtr;
1401122b058aSross         (void) testFlagsFunctionPtr();
1402122b058aSross         testZ = testFunction( testCases_a_float64 );
1403122b058aSross         testFlags = testFlagsFunctionPtr();
1404122b058aSross         --count;
1405122b058aSross         if ( count == 0 ) {
1406122b058aSross             checkEarlyExit();
1407122b058aSross             count = 10000;
1408122b058aSross         }
1409122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1410122b058aSross             if (    ! checkNaNs
1411122b058aSross                  && float64_is_signaling_nan( testCases_a_float64 ) ) {
1412122b058aSross                 trueFlags |= float_flag_invalid;
1413122b058aSross             }
1414122b058aSross             if (    ( trueZ == 0x7FFFFFFF )
1415122b058aSross                  && (    ( testZ == 0x7FFFFFFF )
1416122b058aSross                       || ( testZ == (sbits32) 0x80000000 ) )
1417122b058aSross                  && ( trueFlags == float_flag_invalid )
1418122b058aSross                  && ( testFlags == float_flag_invalid )
1419122b058aSross                ) {
1420122b058aSross                 /* no problem */
1421122b058aSross             }
1422122b058aSross             else {
1423122b058aSross                 ++errorCount;
1424122b058aSross                 writeErrorFound( 10000 - count );
1425122b058aSross                 writeInput_a_float64();
1426122b058aSross                 fputs( "  ", stdout );
1427122b058aSross                 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags );
1428122b058aSross                 fflush( stdout );
1429122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1430122b058aSross             }
1431122b058aSross         }
1432122b058aSross     }
1433122b058aSross  exit:
1434122b058aSross     writeTestsPerformed( 10000 - count );
1435122b058aSross 
1436122b058aSross }
1437122b058aSross 
1438122b058aSross #ifdef BITS64
1439122b058aSross 
1440122b058aSross void
test_a_float64_z_int64(int64 trueFunction (float64),int64 testFunction (float64))1441122b058aSross  test_a_float64_z_int64(
1442122b058aSross      int64 trueFunction( float64 ), int64 testFunction( float64 ) )
1443122b058aSross {
1444122b058aSross     int16 count;
1445122b058aSross     int64 trueZ, testZ;
1446122b058aSross     uint8 trueFlags, testFlags;
1447122b058aSross 
1448122b058aSross     errorCount = 0;
1449122b058aSross     tenthousandsCount = 0;
1450122b058aSross     count = 10000;
1451122b058aSross     testCases_initSequence( testCases_sequence_a_float64 );
1452122b058aSross     writeTestsTotal();
1453122b058aSross     while ( ! testCases_done || forever ) {
1454122b058aSross         testCases_next();
1455122b058aSross         *trueFlagsPtr = 0;
1456122b058aSross         trueZ = trueFunction( testCases_a_float64 );
1457122b058aSross         trueFlags = *trueFlagsPtr;
1458122b058aSross         (void) testFlagsFunctionPtr();
1459122b058aSross         testZ = testFunction( testCases_a_float64 );
1460122b058aSross         testFlags = testFlagsFunctionPtr();
1461122b058aSross         --count;
1462122b058aSross         if ( count == 0 ) {
1463122b058aSross             checkEarlyExit();
1464122b058aSross             count = 10000;
1465122b058aSross         }
1466122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1467122b058aSross             if (    ! checkNaNs
1468122b058aSross                  && float64_is_signaling_nan( testCases_a_float64 ) ) {
1469122b058aSross                 trueFlags |= float_flag_invalid;
1470122b058aSross             }
1471122b058aSross             if (    ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1472122b058aSross                  && (    ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1473122b058aSross                       || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) )
1474122b058aSross                  && ( trueFlags == float_flag_invalid )
1475122b058aSross                  && ( testFlags == float_flag_invalid )
1476122b058aSross                ) {
1477122b058aSross                 /* no problem */
1478122b058aSross             }
1479122b058aSross             else {
1480122b058aSross                 ++errorCount;
1481122b058aSross                 writeErrorFound( 10000 - count );
1482122b058aSross                 writeInput_a_float64();
1483122b058aSross                 fputs( "  ", stdout );
1484122b058aSross                 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags );
1485122b058aSross                 fflush( stdout );
1486122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1487122b058aSross             }
1488122b058aSross         }
1489122b058aSross     }
1490122b058aSross  exit:
1491122b058aSross     writeTestsPerformed( 10000 - count );
1492122b058aSross 
1493122b058aSross }
1494122b058aSross 
1495122b058aSross #endif
1496122b058aSross 
1497122b058aSross void
test_a_float64_z_float32(float32 trueFunction (float64),float32 testFunction (float64))1498122b058aSross  test_a_float64_z_float32(
1499122b058aSross      float32 trueFunction( float64 ), float32 testFunction( float64 ) )
1500122b058aSross {
1501122b058aSross     int16 count;
1502122b058aSross     float32 trueZ, testZ;
1503122b058aSross     uint8 trueFlags, testFlags;
1504122b058aSross 
1505122b058aSross     errorCount = 0;
1506122b058aSross     tenthousandsCount = 0;
1507122b058aSross     count = 10000;
1508122b058aSross     testCases_initSequence( testCases_sequence_a_float64 );
1509122b058aSross     writeTestsTotal();
1510122b058aSross     while ( ! testCases_done || forever ) {
1511122b058aSross         testCases_next();
1512122b058aSross         *trueFlagsPtr = 0;
1513122b058aSross         trueZ = trueFunction( testCases_a_float64 );
1514122b058aSross         trueFlags = *trueFlagsPtr;
1515122b058aSross         (void) testFlagsFunctionPtr();
1516122b058aSross         testZ = testFunction( testCases_a_float64 );
1517122b058aSross         testFlags = testFlagsFunctionPtr();
1518122b058aSross         --count;
1519122b058aSross         if ( count == 0 ) {
1520122b058aSross             checkEarlyExit();
1521122b058aSross             count = 10000;
1522122b058aSross         }
1523122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1524122b058aSross             if (    ! checkNaNs
1525122b058aSross                  && float64_is_signaling_nan( testCases_a_float64 ) ) {
1526122b058aSross                 trueFlags |= float_flag_invalid;
1527122b058aSross             }
1528122b058aSross             if (    ! checkNaNs
1529122b058aSross                  && float32_isNaN( trueZ )
1530122b058aSross                  && float32_isNaN( testZ )
1531122b058aSross                  && ! float32_is_signaling_nan( testZ )
1532122b058aSross                  && ( trueFlags == testFlags )
1533122b058aSross                ) {
1534122b058aSross                 /* no problem */
1535122b058aSross             }
1536122b058aSross             else {
1537122b058aSross                 ++errorCount;
1538122b058aSross                 writeErrorFound( 10000 - count );
1539122b058aSross                 writeInput_a_float64();
1540122b058aSross                 fputs( "  ", stdout );
1541122b058aSross                 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
1542122b058aSross                 fflush( stdout );
1543122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1544122b058aSross             }
1545122b058aSross         }
1546122b058aSross     }
1547122b058aSross  exit:
1548122b058aSross     writeTestsPerformed( 10000 - count );
1549122b058aSross 
1550122b058aSross }
1551122b058aSross 
1552122b058aSross #ifdef FLOATX80
1553122b058aSross 
1554122b058aSross void
test_a_float64_z_floatx80(floatx80 trueFunction (float64),floatx80 testFunction (float64))1555122b058aSross  test_a_float64_z_floatx80(
1556122b058aSross      floatx80 trueFunction( float64 ), floatx80 testFunction( float64 ) )
1557122b058aSross {
1558122b058aSross     int16 count;
1559122b058aSross     floatx80 trueZ, testZ;
1560122b058aSross     uint8 trueFlags, testFlags;
1561122b058aSross 
1562122b058aSross     errorCount = 0;
1563122b058aSross     tenthousandsCount = 0;
1564122b058aSross     count = 10000;
1565122b058aSross     testCases_initSequence( testCases_sequence_a_float64 );
1566122b058aSross     writeTestsTotal();
1567122b058aSross     while ( ! testCases_done || forever ) {
1568122b058aSross         testCases_next();
1569122b058aSross         *trueFlagsPtr = 0;
1570122b058aSross         trueZ = trueFunction( testCases_a_float64 );
1571122b058aSross         trueFlags = *trueFlagsPtr;
1572122b058aSross         (void) testFlagsFunctionPtr();
1573122b058aSross         testZ = testFunction( testCases_a_float64 );
1574122b058aSross         testFlags = testFlagsFunctionPtr();
1575122b058aSross         --count;
1576122b058aSross         if ( count == 0 ) {
1577122b058aSross             checkEarlyExit();
1578122b058aSross             count = 10000;
1579122b058aSross         }
1580122b058aSross         if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1581122b058aSross             if (    ! checkNaNs
1582122b058aSross                  && float64_is_signaling_nan( testCases_a_float64 ) ) {
1583122b058aSross                 trueFlags |= float_flag_invalid;
1584122b058aSross             }
1585122b058aSross             if (    ! checkNaNs
1586122b058aSross                  && floatx80_isNaN( trueZ )
1587122b058aSross                  && floatx80_isNaN( testZ )
1588122b058aSross                  && ! floatx80_is_signaling_nan( testZ )
1589122b058aSross                  && ( trueFlags == testFlags )
1590122b058aSross                ) {
1591122b058aSross                 /* no problem */
1592122b058aSross             }
1593122b058aSross             else {
1594122b058aSross                 ++errorCount;
1595122b058aSross                 writeErrorFound( 10000 - count );
1596122b058aSross                 writeInput_a_float64();
1597122b058aSross                 fputs( "\n\t", stdout );
1598122b058aSross                 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
1599122b058aSross                 fflush( stdout );
1600122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1601122b058aSross             }
1602122b058aSross         }
1603122b058aSross     }
1604122b058aSross  exit:
1605122b058aSross     writeTestsPerformed( 10000 - count );
1606122b058aSross 
1607122b058aSross }
1608122b058aSross 
1609122b058aSross #endif
1610122b058aSross 
1611122b058aSross #ifdef FLOAT128
1612122b058aSross 
1613122b058aSross void
test_a_float64_z_float128(float128 trueFunction (float64),float128 testFunction (float64))1614122b058aSross  test_a_float64_z_float128(
1615122b058aSross      float128 trueFunction( float64 ), float128 testFunction( float64 ) )
1616122b058aSross {
1617122b058aSross     int16 count;
1618122b058aSross     float128 trueZ, testZ;
1619122b058aSross     uint8 trueFlags, testFlags;
1620122b058aSross 
1621122b058aSross     errorCount = 0;
1622122b058aSross     tenthousandsCount = 0;
1623122b058aSross     count = 10000;
1624122b058aSross     testCases_initSequence( testCases_sequence_a_float64 );
1625122b058aSross     writeTestsTotal();
1626122b058aSross     while ( ! testCases_done || forever ) {
1627122b058aSross         testCases_next();
1628122b058aSross         *trueFlagsPtr = 0;
1629122b058aSross         trueZ = trueFunction( testCases_a_float64 );
1630122b058aSross         trueFlags = *trueFlagsPtr;
1631122b058aSross         (void) testFlagsFunctionPtr();
1632122b058aSross         testZ = testFunction( testCases_a_float64 );
1633122b058aSross         testFlags = testFlagsFunctionPtr();
1634122b058aSross         --count;
1635122b058aSross         if ( count == 0 ) {
1636122b058aSross             checkEarlyExit();
1637122b058aSross             count = 10000;
1638122b058aSross         }
1639122b058aSross         if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1640122b058aSross             if (    ! checkNaNs
1641122b058aSross                  && float64_is_signaling_nan( testCases_a_float64 ) ) {
1642122b058aSross                 trueFlags |= float_flag_invalid;
1643122b058aSross             }
1644122b058aSross             if (    ! checkNaNs
1645122b058aSross                  && float128_isNaN( trueZ )
1646122b058aSross                  && float128_isNaN( testZ )
1647122b058aSross                  && ! float128_is_signaling_nan( testZ )
1648122b058aSross                  && ( trueFlags == testFlags )
1649122b058aSross                ) {
1650122b058aSross                 /* no problem */
1651122b058aSross             }
1652122b058aSross             else {
1653122b058aSross                 ++errorCount;
1654122b058aSross                 writeErrorFound( 10000 - count );
1655122b058aSross                 writeInput_a_float64();
1656122b058aSross                 fputs( "\n\t", stdout );
1657122b058aSross                 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
1658122b058aSross                 fflush( stdout );
1659122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1660122b058aSross             }
1661122b058aSross         }
1662122b058aSross     }
1663122b058aSross  exit:
1664122b058aSross     writeTestsPerformed( 10000 - count );
1665122b058aSross 
1666122b058aSross }
1667122b058aSross 
1668122b058aSross #endif
1669122b058aSross 
1670122b058aSross void
test_az_float64(float64 trueFunction (float64),float64 testFunction (float64))1671122b058aSross  test_az_float64(
1672122b058aSross      float64 trueFunction( float64 ), float64 testFunction( float64 ) )
1673122b058aSross {
1674122b058aSross     int16 count;
1675122b058aSross     float64 trueZ, testZ;
1676122b058aSross     uint8 trueFlags, testFlags;
1677122b058aSross 
1678122b058aSross     errorCount = 0;
1679122b058aSross     tenthousandsCount = 0;
1680122b058aSross     count = 10000;
1681122b058aSross     testCases_initSequence( testCases_sequence_a_float64 );
1682122b058aSross     writeTestsTotal();
1683122b058aSross     while ( ! testCases_done || forever ) {
1684122b058aSross         testCases_next();
1685122b058aSross         *trueFlagsPtr = 0;
1686122b058aSross         trueZ = trueFunction( testCases_a_float64 );
1687122b058aSross         trueFlags = *trueFlagsPtr;
1688122b058aSross         (void) testFlagsFunctionPtr();
1689122b058aSross         testZ = testFunction( testCases_a_float64 );
1690122b058aSross         testFlags = testFlagsFunctionPtr();
1691122b058aSross         --count;
1692122b058aSross         if ( count == 0 ) {
1693122b058aSross             checkEarlyExit();
1694122b058aSross             count = 10000;
1695122b058aSross         }
1696122b058aSross         if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1697122b058aSross             if (    ! checkNaNs
1698122b058aSross                  && float64_is_signaling_nan( testCases_a_float64 ) ) {
1699122b058aSross                 trueFlags |= float_flag_invalid;
1700122b058aSross             }
1701122b058aSross             if (    ! checkNaNs
1702122b058aSross                  && float64_isNaN( trueZ )
1703122b058aSross                  && float64_isNaN( testZ )
1704122b058aSross                  && ! float64_is_signaling_nan( testZ )
1705122b058aSross                  && ( trueFlags == testFlags )
1706122b058aSross                ) {
1707122b058aSross                 /* no problem */
1708122b058aSross             }
1709122b058aSross             else {
1710122b058aSross                 ++errorCount;
1711122b058aSross                 writeErrorFound( 10000 - count );
1712122b058aSross                 writeInput_a_float64();
1713122b058aSross                 fputs( "  ", stdout );
1714122b058aSross                 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
1715122b058aSross                 fflush( stdout );
1716122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1717122b058aSross             }
1718122b058aSross         }
1719122b058aSross     }
1720122b058aSross  exit:
1721122b058aSross     writeTestsPerformed( 10000 - count );
1722122b058aSross 
1723122b058aSross }
1724122b058aSross 
1725122b058aSross void
test_ab_float64_z_flag(flag trueFunction (float64,float64),flag testFunction (float64,float64))1726122b058aSross  test_ab_float64_z_flag(
1727122b058aSross      flag trueFunction( float64, float64 ),
1728122b058aSross      flag testFunction( float64, float64 )
1729122b058aSross  )
1730122b058aSross {
1731122b058aSross     int16 count;
1732122b058aSross     flag trueZ, testZ;
1733122b058aSross     uint8 trueFlags, testFlags;
1734122b058aSross 
1735122b058aSross     errorCount = 0;
1736122b058aSross     tenthousandsCount = 0;
1737122b058aSross     count = 10000;
1738122b058aSross     testCases_initSequence( testCases_sequence_ab_float64 );
1739122b058aSross     writeTestsTotal();
1740122b058aSross     while ( ! testCases_done || forever ) {
1741122b058aSross         testCases_next();
1742122b058aSross         *trueFlagsPtr = 0;
1743122b058aSross         trueZ = trueFunction( testCases_a_float64, testCases_b_float64 );
1744122b058aSross         trueFlags = *trueFlagsPtr;
1745122b058aSross         (void) testFlagsFunctionPtr();
1746122b058aSross         testZ = testFunction( testCases_a_float64, testCases_b_float64 );
1747122b058aSross         testFlags = testFlagsFunctionPtr();
1748122b058aSross         --count;
1749122b058aSross         if ( count == 0 ) {
1750122b058aSross             checkEarlyExit();
1751122b058aSross             count = 10000;
1752122b058aSross         }
1753122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1754122b058aSross             if (    ! checkNaNs
1755122b058aSross                  && (    float64_is_signaling_nan( testCases_a_float64 )
1756122b058aSross                       || float64_is_signaling_nan( testCases_b_float64 ) )
1757122b058aSross                ) {
1758122b058aSross                 trueFlags |= float_flag_invalid;
1759122b058aSross             }
1760122b058aSross             if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1761122b058aSross                 ++errorCount;
1762122b058aSross                 writeErrorFound( 10000 - count );
1763122b058aSross                 writeInputs_ab_float64();
1764122b058aSross                 fputs( "  ", stdout );
1765122b058aSross                 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags );
1766122b058aSross                 fflush( stdout );
1767122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1768122b058aSross             }
1769122b058aSross         }
1770122b058aSross     }
1771122b058aSross  exit:
1772122b058aSross     writeTestsPerformed( 10000 - count );
1773122b058aSross     return;
1774122b058aSross 
1775122b058aSross }
1776122b058aSross 
1777122b058aSross void
test_abz_float64(float64 trueFunction (float64,float64),float64 testFunction (float64,float64))1778122b058aSross  test_abz_float64(
1779122b058aSross      float64 trueFunction( float64, float64 ),
1780122b058aSross      float64 testFunction( float64, float64 )
1781122b058aSross  )
1782122b058aSross {
1783122b058aSross     int16 count;
1784122b058aSross     float64 trueZ, testZ;
1785122b058aSross     uint8 trueFlags, testFlags;
1786122b058aSross 
1787122b058aSross     errorCount = 0;
1788122b058aSross     tenthousandsCount = 0;
1789122b058aSross     count = 10000;
1790122b058aSross     testCases_initSequence( testCases_sequence_ab_float64 );
1791122b058aSross     writeTestsTotal();
1792122b058aSross     while ( ! testCases_done || forever ) {
1793122b058aSross         testCases_next();
1794122b058aSross         *trueFlagsPtr = 0;
1795122b058aSross         trueZ = trueFunction( testCases_a_float64, testCases_b_float64 );
1796122b058aSross         trueFlags = *trueFlagsPtr;
1797122b058aSross         (void) testFlagsFunctionPtr();
1798122b058aSross         testZ = testFunction( testCases_a_float64, testCases_b_float64 );
1799122b058aSross         testFlags = testFlagsFunctionPtr();
1800122b058aSross         --count;
1801122b058aSross         if ( count == 0 ) {
1802122b058aSross             checkEarlyExit();
1803122b058aSross             count = 10000;
1804122b058aSross         }
1805122b058aSross         if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
1806122b058aSross             if (    ! checkNaNs
1807122b058aSross                  && (    float64_is_signaling_nan( testCases_a_float64 )
1808122b058aSross                       || float64_is_signaling_nan( testCases_b_float64 ) )
1809122b058aSross                ) {
1810122b058aSross                 trueFlags |= float_flag_invalid;
1811122b058aSross             }
1812122b058aSross             if (    ! checkNaNs
1813122b058aSross                  && float64_isNaN( trueZ )
1814122b058aSross                  && float64_isNaN( testZ )
1815122b058aSross                  && ! float64_is_signaling_nan( testZ )
1816122b058aSross                  && ( trueFlags == testFlags )
1817122b058aSross                ) {
1818122b058aSross                 /* no problem */
1819122b058aSross             }
1820122b058aSross             else {
1821122b058aSross                 ++errorCount;
1822122b058aSross                 writeErrorFound( 10000 - count );
1823122b058aSross                 writeInputs_ab_float64();
1824122b058aSross                 fputs( "\n\t", stdout );
1825122b058aSross                 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
1826122b058aSross                 fflush( stdout );
1827122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1828122b058aSross             }
1829122b058aSross         }
1830122b058aSross     }
1831122b058aSross  exit:
1832122b058aSross     writeTestsPerformed( 10000 - count );
1833122b058aSross     return;
1834122b058aSross 
1835122b058aSross }
1836122b058aSross 
1837122b058aSross #ifdef FLOATX80
1838122b058aSross 
1839122b058aSross void
test_a_floatx80_z_int32(int32 trueFunction (floatx80),int32 testFunction (floatx80))1840122b058aSross  test_a_floatx80_z_int32(
1841122b058aSross      int32 trueFunction( floatx80 ), int32 testFunction( floatx80 ) )
1842122b058aSross {
1843122b058aSross     int16 count;
1844122b058aSross     int32 trueZ, testZ;
1845122b058aSross     uint8 trueFlags, testFlags;
1846122b058aSross 
1847122b058aSross     errorCount = 0;
1848122b058aSross     tenthousandsCount = 0;
1849122b058aSross     count = 10000;
1850122b058aSross     testCases_initSequence( testCases_sequence_a_floatx80 );
1851122b058aSross     writeTestsTotal();
1852122b058aSross     while ( ! testCases_done || forever ) {
1853122b058aSross         testCases_next();
1854122b058aSross         *trueFlagsPtr = 0;
1855122b058aSross         trueZ = trueFunction( testCases_a_floatx80 );
1856122b058aSross         trueFlags = *trueFlagsPtr;
1857122b058aSross         (void) testFlagsFunctionPtr();
1858122b058aSross         testZ = testFunction( testCases_a_floatx80 );
1859122b058aSross         testFlags = testFlagsFunctionPtr();
1860122b058aSross         --count;
1861122b058aSross         if ( count == 0 ) {
1862122b058aSross             checkEarlyExit();
1863122b058aSross             count = 10000;
1864122b058aSross         }
1865122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1866122b058aSross             if (    ! checkNaNs
1867122b058aSross                  && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
1868122b058aSross                 trueFlags |= float_flag_invalid;
1869122b058aSross             }
1870122b058aSross             if (    ( trueZ == 0x7FFFFFFF )
1871122b058aSross                  && (    ( testZ == 0x7FFFFFFF )
1872122b058aSross                       || ( testZ == (sbits32) 0x80000000 ) )
1873122b058aSross                  && ( trueFlags == float_flag_invalid )
1874122b058aSross                  && ( testFlags == float_flag_invalid )
1875122b058aSross                ) {
1876122b058aSross                 /* no problem */
1877122b058aSross             }
1878122b058aSross             else {
1879122b058aSross                 ++errorCount;
1880122b058aSross                 writeErrorFound( 10000 - count );
1881122b058aSross                 writeInput_a_floatx80();
1882122b058aSross                 fputs( "  ", stdout );
1883122b058aSross                 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags );
1884122b058aSross                 fflush( stdout );
1885122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1886122b058aSross             }
1887122b058aSross         }
1888122b058aSross     }
1889122b058aSross  exit:
1890122b058aSross     writeTestsPerformed( 10000 - count );
1891122b058aSross 
1892122b058aSross }
1893122b058aSross 
1894122b058aSross #ifdef BITS64
1895122b058aSross 
1896122b058aSross void
test_a_floatx80_z_int64(int64 trueFunction (floatx80),int64 testFunction (floatx80))1897122b058aSross  test_a_floatx80_z_int64(
1898122b058aSross      int64 trueFunction( floatx80 ), int64 testFunction( floatx80 ) )
1899122b058aSross {
1900122b058aSross     int16 count;
1901122b058aSross     int64 trueZ, testZ;
1902122b058aSross     uint8 trueFlags, testFlags;
1903122b058aSross 
1904122b058aSross     errorCount = 0;
1905122b058aSross     tenthousandsCount = 0;
1906122b058aSross     count = 10000;
1907122b058aSross     testCases_initSequence( testCases_sequence_a_floatx80 );
1908122b058aSross     writeTestsTotal();
1909122b058aSross     while ( ! testCases_done || forever ) {
1910122b058aSross         testCases_next();
1911122b058aSross         *trueFlagsPtr = 0;
1912122b058aSross         trueZ = trueFunction( testCases_a_floatx80 );
1913122b058aSross         trueFlags = *trueFlagsPtr;
1914122b058aSross         (void) testFlagsFunctionPtr();
1915122b058aSross         testZ = testFunction( testCases_a_floatx80 );
1916122b058aSross         testFlags = testFlagsFunctionPtr();
1917122b058aSross         --count;
1918122b058aSross         if ( count == 0 ) {
1919122b058aSross             checkEarlyExit();
1920122b058aSross             count = 10000;
1921122b058aSross         }
1922122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1923122b058aSross             if (    ! checkNaNs
1924122b058aSross                  && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
1925122b058aSross                 trueFlags |= float_flag_invalid;
1926122b058aSross             }
1927122b058aSross             if (    ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1928122b058aSross                  && (    ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
1929122b058aSross                       || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) )
1930122b058aSross                  && ( trueFlags == float_flag_invalid )
1931122b058aSross                  && ( testFlags == float_flag_invalid )
1932122b058aSross                ) {
1933122b058aSross                 /* no problem */
1934122b058aSross             }
1935122b058aSross             else {
1936122b058aSross                 ++errorCount;
1937122b058aSross                 writeErrorFound( 10000 - count );
1938122b058aSross                 writeInput_a_floatx80();
1939122b058aSross                 fputs( "  ", stdout );
1940122b058aSross                 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags );
1941122b058aSross                 fflush( stdout );
1942122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
1943122b058aSross             }
1944122b058aSross         }
1945122b058aSross     }
1946122b058aSross  exit:
1947122b058aSross     writeTestsPerformed( 10000 - count );
1948122b058aSross 
1949122b058aSross }
1950122b058aSross 
1951122b058aSross #endif
1952122b058aSross 
1953122b058aSross void
test_a_floatx80_z_float32(float32 trueFunction (floatx80),float32 testFunction (floatx80))1954122b058aSross  test_a_floatx80_z_float32(
1955122b058aSross      float32 trueFunction( floatx80 ), float32 testFunction( floatx80 ) )
1956122b058aSross {
1957122b058aSross     int16 count;
1958122b058aSross     float32 trueZ, testZ;
1959122b058aSross     uint8 trueFlags, testFlags;
1960122b058aSross 
1961122b058aSross     errorCount = 0;
1962122b058aSross     tenthousandsCount = 0;
1963122b058aSross     count = 10000;
1964122b058aSross     testCases_initSequence( testCases_sequence_a_floatx80 );
1965122b058aSross     writeTestsTotal();
1966122b058aSross     while ( ! testCases_done || forever ) {
1967122b058aSross         testCases_next();
1968122b058aSross         *trueFlagsPtr = 0;
1969122b058aSross         trueZ = trueFunction( testCases_a_floatx80 );
1970122b058aSross         trueFlags = *trueFlagsPtr;
1971122b058aSross         (void) testFlagsFunctionPtr();
1972122b058aSross         testZ = testFunction( testCases_a_floatx80 );
1973122b058aSross         testFlags = testFlagsFunctionPtr();
1974122b058aSross         --count;
1975122b058aSross         if ( count == 0 ) {
1976122b058aSross             checkEarlyExit();
1977122b058aSross             count = 10000;
1978122b058aSross         }
1979122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
1980122b058aSross             if (    ! checkNaNs
1981122b058aSross                  && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
1982122b058aSross                 trueFlags |= float_flag_invalid;
1983122b058aSross             }
1984122b058aSross             if (    ! checkNaNs
1985122b058aSross                  && float32_isNaN( trueZ )
1986122b058aSross                  && float32_isNaN( testZ )
1987122b058aSross                  && ! float32_is_signaling_nan( testZ )
1988122b058aSross                  && ( trueFlags == testFlags )
1989122b058aSross                ) {
1990122b058aSross                 /* no problem */
1991122b058aSross             }
1992122b058aSross             else {
1993122b058aSross                 ++errorCount;
1994122b058aSross                 writeErrorFound( 10000 - count );
1995122b058aSross                 writeInput_a_floatx80();
1996122b058aSross                 fputs( "  ", stdout );
1997122b058aSross                 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
1998122b058aSross                 fflush( stdout );
1999122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2000122b058aSross             }
2001122b058aSross         }
2002122b058aSross     }
2003122b058aSross  exit:
2004122b058aSross     writeTestsPerformed( 10000 - count );
2005122b058aSross 
2006122b058aSross }
2007122b058aSross 
2008122b058aSross void
test_a_floatx80_z_float64(float64 trueFunction (floatx80),float64 testFunction (floatx80))2009122b058aSross  test_a_floatx80_z_float64(
2010122b058aSross      float64 trueFunction( floatx80 ), float64 testFunction( floatx80 ) )
2011122b058aSross {
2012122b058aSross     int16 count;
2013122b058aSross     float64 trueZ, testZ;
2014122b058aSross     uint8 trueFlags, testFlags;
2015122b058aSross 
2016122b058aSross     errorCount = 0;
2017122b058aSross     tenthousandsCount = 0;
2018122b058aSross     count = 10000;
2019122b058aSross     testCases_initSequence( testCases_sequence_a_floatx80 );
2020122b058aSross     writeTestsTotal();
2021122b058aSross     while ( ! testCases_done || forever ) {
2022122b058aSross         testCases_next();
2023122b058aSross         *trueFlagsPtr = 0;
2024122b058aSross         trueZ = trueFunction( testCases_a_floatx80 );
2025122b058aSross         trueFlags = *trueFlagsPtr;
2026122b058aSross         (void) testFlagsFunctionPtr();
2027122b058aSross         testZ = testFunction( testCases_a_floatx80 );
2028122b058aSross         testFlags = testFlagsFunctionPtr();
2029122b058aSross         --count;
2030122b058aSross         if ( count == 0 ) {
2031122b058aSross             checkEarlyExit();
2032122b058aSross             count = 10000;
2033122b058aSross         }
2034122b058aSross         if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2035122b058aSross             if (    ! checkNaNs
2036122b058aSross                  && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
2037122b058aSross                 trueFlags |= float_flag_invalid;
2038122b058aSross             }
2039122b058aSross             if (    ! checkNaNs
2040122b058aSross                  && float64_isNaN( trueZ )
2041122b058aSross                  && float64_isNaN( testZ )
2042122b058aSross                  && ! float64_is_signaling_nan( testZ )
2043122b058aSross                  && ( trueFlags == testFlags )
2044122b058aSross                ) {
2045122b058aSross                 /* no problem */
2046122b058aSross             }
2047122b058aSross             else {
2048122b058aSross                 ++errorCount;
2049122b058aSross                 writeErrorFound( 10000 - count );
2050122b058aSross                 writeInput_a_floatx80();
2051122b058aSross                 fputs( "\n\t", stdout );
2052122b058aSross                 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
2053122b058aSross                 fflush( stdout );
2054122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2055122b058aSross             }
2056122b058aSross         }
2057122b058aSross     }
2058122b058aSross  exit:
2059122b058aSross     writeTestsPerformed( 10000 - count );
2060122b058aSross 
2061122b058aSross }
2062122b058aSross 
2063122b058aSross #ifdef FLOAT128
2064122b058aSross 
2065122b058aSross void
test_a_floatx80_z_float128(float128 trueFunction (floatx80),float128 testFunction (floatx80))2066122b058aSross  test_a_floatx80_z_float128(
2067122b058aSross      float128 trueFunction( floatx80 ), float128 testFunction( floatx80 ) )
2068122b058aSross {
2069122b058aSross     int16 count;
2070122b058aSross     float128 trueZ, testZ;
2071122b058aSross     uint8 trueFlags, testFlags;
2072122b058aSross 
2073122b058aSross     errorCount = 0;
2074122b058aSross     tenthousandsCount = 0;
2075122b058aSross     count = 10000;
2076122b058aSross     testCases_initSequence( testCases_sequence_a_floatx80 );
2077122b058aSross     writeTestsTotal();
2078122b058aSross     while ( ! testCases_done || forever ) {
2079122b058aSross         testCases_next();
2080122b058aSross         *trueFlagsPtr = 0;
2081122b058aSross         trueZ = trueFunction( testCases_a_floatx80 );
2082122b058aSross         trueFlags = *trueFlagsPtr;
2083122b058aSross         (void) testFlagsFunctionPtr();
2084122b058aSross         testZ = testFunction( testCases_a_floatx80 );
2085122b058aSross         testFlags = testFlagsFunctionPtr();
2086122b058aSross         --count;
2087122b058aSross         if ( count == 0 ) {
2088122b058aSross             checkEarlyExit();
2089122b058aSross             count = 10000;
2090122b058aSross         }
2091122b058aSross         if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2092122b058aSross             if (    ! checkNaNs
2093122b058aSross                  && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
2094122b058aSross                 trueFlags |= float_flag_invalid;
2095122b058aSross             }
2096122b058aSross             if (    ! checkNaNs
2097122b058aSross                  && float128_isNaN( trueZ )
2098122b058aSross                  && float128_isNaN( testZ )
2099122b058aSross                  && ! float128_is_signaling_nan( testZ )
2100122b058aSross                  && ( trueFlags == testFlags )
2101122b058aSross                ) {
2102122b058aSross                 /* no problem */
2103122b058aSross             }
2104122b058aSross             else {
2105122b058aSross                 ++errorCount;
2106122b058aSross                 writeErrorFound( 10000 - count );
2107122b058aSross                 writeInput_a_floatx80();
2108122b058aSross                 fputs( "\n\t", stdout );
2109122b058aSross                 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
2110122b058aSross                 fflush( stdout );
2111122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2112122b058aSross             }
2113122b058aSross         }
2114122b058aSross     }
2115122b058aSross  exit:
2116122b058aSross     writeTestsPerformed( 10000 - count );
2117122b058aSross 
2118122b058aSross }
2119122b058aSross 
2120122b058aSross #endif
2121122b058aSross 
2122122b058aSross void
test_az_floatx80(floatx80 trueFunction (floatx80),floatx80 testFunction (floatx80))2123122b058aSross  test_az_floatx80(
2124122b058aSross      floatx80 trueFunction( floatx80 ), floatx80 testFunction( floatx80 ) )
2125122b058aSross {
2126122b058aSross     int16 count;
2127122b058aSross     floatx80 trueZ, testZ;
2128122b058aSross     uint8 trueFlags, testFlags;
2129122b058aSross 
2130122b058aSross     errorCount = 0;
2131122b058aSross     tenthousandsCount = 0;
2132122b058aSross     count = 10000;
2133122b058aSross     testCases_initSequence( testCases_sequence_a_floatx80 );
2134122b058aSross     writeTestsTotal();
2135122b058aSross     while ( ! testCases_done || forever ) {
2136122b058aSross         testCases_next();
2137122b058aSross         *trueFlagsPtr = 0;
2138122b058aSross         trueZ = trueFunction( testCases_a_floatx80 );
2139122b058aSross         trueFlags = *trueFlagsPtr;
2140122b058aSross         (void) testFlagsFunctionPtr();
2141122b058aSross         testZ = testFunction( testCases_a_floatx80 );
2142122b058aSross         testFlags = testFlagsFunctionPtr();
2143122b058aSross         --count;
2144122b058aSross         if ( count == 0 ) {
2145122b058aSross             checkEarlyExit();
2146122b058aSross             count = 10000;
2147122b058aSross         }
2148122b058aSross         if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2149122b058aSross             if (    ! checkNaNs
2150122b058aSross                  && floatx80_is_signaling_nan( testCases_a_floatx80 ) ) {
2151122b058aSross                 trueFlags |= float_flag_invalid;
2152122b058aSross             }
2153122b058aSross             if (    ! checkNaNs
2154122b058aSross                  && floatx80_isNaN( trueZ )
2155122b058aSross                  && floatx80_isNaN( testZ )
2156122b058aSross                  && ! floatx80_is_signaling_nan( testZ )
2157122b058aSross                  && ( trueFlags == testFlags )
2158122b058aSross                ) {
2159122b058aSross                 /* no problem */
2160122b058aSross             }
2161122b058aSross             else {
2162122b058aSross                 ++errorCount;
2163122b058aSross                 writeErrorFound( 10000 - count );
2164122b058aSross                 writeInput_a_floatx80();
2165122b058aSross                 fputs( "\n\t", stdout );
2166122b058aSross                 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
2167122b058aSross                 fflush( stdout );
2168122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2169122b058aSross             }
2170122b058aSross         }
2171122b058aSross     }
2172122b058aSross  exit:
2173122b058aSross     writeTestsPerformed( 10000 - count );
2174122b058aSross 
2175122b058aSross }
2176122b058aSross 
2177122b058aSross void
test_ab_floatx80_z_flag(flag trueFunction (floatx80,floatx80),flag testFunction (floatx80,floatx80))2178122b058aSross  test_ab_floatx80_z_flag(
2179122b058aSross      flag trueFunction( floatx80, floatx80 ),
2180122b058aSross      flag testFunction( floatx80, floatx80 )
2181122b058aSross  )
2182122b058aSross {
2183122b058aSross     int16 count;
2184122b058aSross     flag trueZ, testZ;
2185122b058aSross     uint8 trueFlags, testFlags;
2186122b058aSross 
2187122b058aSross     errorCount = 0;
2188122b058aSross     tenthousandsCount = 0;
2189122b058aSross     count = 10000;
2190122b058aSross     testCases_initSequence( testCases_sequence_ab_floatx80 );
2191122b058aSross     writeTestsTotal();
2192122b058aSross     while ( ! testCases_done || forever ) {
2193122b058aSross         testCases_next();
2194122b058aSross         *trueFlagsPtr = 0;
2195122b058aSross         trueZ = trueFunction( testCases_a_floatx80, testCases_b_floatx80 );
2196122b058aSross         trueFlags = *trueFlagsPtr;
2197122b058aSross         (void) testFlagsFunctionPtr();
2198122b058aSross         testZ = testFunction( testCases_a_floatx80, testCases_b_floatx80 );
2199122b058aSross         testFlags = testFlagsFunctionPtr();
2200122b058aSross         --count;
2201122b058aSross         if ( count == 0 ) {
2202122b058aSross             checkEarlyExit();
2203122b058aSross             count = 10000;
2204122b058aSross         }
2205122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2206122b058aSross             if (    ! checkNaNs
2207122b058aSross                  && (    floatx80_is_signaling_nan( testCases_a_floatx80 )
2208122b058aSross                       || floatx80_is_signaling_nan( testCases_b_floatx80 ) )
2209122b058aSross                ) {
2210122b058aSross                 trueFlags |= float_flag_invalid;
2211122b058aSross             }
2212122b058aSross             if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2213122b058aSross                 ++errorCount;
2214122b058aSross                 writeErrorFound( 10000 - count );
2215122b058aSross                 writeInputs_ab_floatx80();
2216122b058aSross                 fputs( "  ", stdout );
2217122b058aSross                 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags );
2218122b058aSross                 fflush( stdout );
2219122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2220122b058aSross             }
2221122b058aSross         }
2222122b058aSross     }
2223122b058aSross  exit:
2224122b058aSross     writeTestsPerformed( 10000 - count );
2225122b058aSross     return;
2226122b058aSross 
2227122b058aSross }
2228122b058aSross 
2229122b058aSross void
test_abz_floatx80(floatx80 trueFunction (floatx80,floatx80),floatx80 testFunction (floatx80,floatx80))2230122b058aSross  test_abz_floatx80(
2231122b058aSross      floatx80 trueFunction( floatx80, floatx80 ),
2232122b058aSross      floatx80 testFunction( floatx80, floatx80 )
2233122b058aSross  )
2234122b058aSross {
2235122b058aSross     int16 count;
2236122b058aSross     floatx80 trueZ, testZ;
2237122b058aSross     uint8 trueFlags, testFlags;
2238122b058aSross 
2239122b058aSross     errorCount = 0;
2240122b058aSross     tenthousandsCount = 0;
2241122b058aSross     count = 10000;
2242122b058aSross     testCases_initSequence( testCases_sequence_ab_floatx80 );
2243122b058aSross     writeTestsTotal();
2244122b058aSross     while ( ! testCases_done || forever ) {
2245122b058aSross         testCases_next();
2246122b058aSross         *trueFlagsPtr = 0;
2247122b058aSross         trueZ = trueFunction( testCases_a_floatx80, testCases_b_floatx80 );
2248122b058aSross         trueFlags = *trueFlagsPtr;
2249122b058aSross         (void) testFlagsFunctionPtr();
2250122b058aSross         testZ = testFunction( testCases_a_floatx80, testCases_b_floatx80 );
2251122b058aSross         testFlags = testFlagsFunctionPtr();
2252122b058aSross         --count;
2253122b058aSross         if ( count == 0 ) {
2254122b058aSross             checkEarlyExit();
2255122b058aSross             count = 10000;
2256122b058aSross         }
2257122b058aSross         if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2258122b058aSross             if (    ! checkNaNs
2259122b058aSross                  && (    floatx80_is_signaling_nan( testCases_a_floatx80 )
2260122b058aSross                       || floatx80_is_signaling_nan( testCases_b_floatx80 ) )
2261122b058aSross                ) {
2262122b058aSross                 trueFlags |= float_flag_invalid;
2263122b058aSross             }
2264122b058aSross             if (    ! checkNaNs
2265122b058aSross                  && floatx80_isNaN( trueZ )
2266122b058aSross                  && floatx80_isNaN( testZ )
2267122b058aSross                  && ! floatx80_is_signaling_nan( testZ )
2268122b058aSross                  && ( trueFlags == testFlags )
2269122b058aSross                ) {
2270122b058aSross                 /* no problem */
2271122b058aSross             }
2272122b058aSross             else {
2273122b058aSross                 ++errorCount;
2274122b058aSross                 writeErrorFound( 10000 - count );
2275122b058aSross                 writeInputs_ab_floatx80();
2276122b058aSross                 fputs( "\n\t", stdout );
2277122b058aSross                 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
2278122b058aSross                 fflush( stdout );
2279122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2280122b058aSross             }
2281122b058aSross         }
2282122b058aSross     }
2283122b058aSross  exit:
2284122b058aSross     writeTestsPerformed( 10000 - count );
2285122b058aSross     return;
2286122b058aSross 
2287122b058aSross }
2288122b058aSross 
2289122b058aSross #endif
2290122b058aSross 
2291122b058aSross #ifdef FLOAT128
2292122b058aSross 
2293122b058aSross void
test_a_float128_z_int32(int32 trueFunction (float128),int32 testFunction (float128))2294122b058aSross  test_a_float128_z_int32(
2295122b058aSross      int32 trueFunction( float128 ), int32 testFunction( float128 ) )
2296122b058aSross {
2297122b058aSross     int16 count;
2298122b058aSross     int32 trueZ, testZ;
2299122b058aSross     uint8 trueFlags, testFlags;
2300122b058aSross 
2301122b058aSross     errorCount = 0;
2302122b058aSross     tenthousandsCount = 0;
2303122b058aSross     count = 10000;
2304122b058aSross     testCases_initSequence( testCases_sequence_a_float128 );
2305122b058aSross     writeTestsTotal();
2306122b058aSross     while ( ! testCases_done || forever ) {
2307122b058aSross         testCases_next();
2308122b058aSross         *trueFlagsPtr = 0;
2309122b058aSross         trueZ = trueFunction( testCases_a_float128 );
2310122b058aSross         trueFlags = *trueFlagsPtr;
2311122b058aSross         (void) testFlagsFunctionPtr();
2312122b058aSross         testZ = testFunction( testCases_a_float128 );
2313122b058aSross         testFlags = testFlagsFunctionPtr();
2314122b058aSross         --count;
2315122b058aSross         if ( count == 0 ) {
2316122b058aSross             checkEarlyExit();
2317122b058aSross             count = 10000;
2318122b058aSross         }
2319122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2320122b058aSross             if (    ! checkNaNs
2321122b058aSross                  && float128_is_signaling_nan( testCases_a_float128 ) ) {
2322122b058aSross                 trueFlags |= float_flag_invalid;
2323122b058aSross             }
2324122b058aSross             if (    ( trueZ == 0x7FFFFFFF )
2325122b058aSross                  && (    ( testZ == 0x7FFFFFFF )
2326122b058aSross                       || ( testZ == (sbits32) 0x80000000 ) )
2327122b058aSross                  && ( trueFlags == float_flag_invalid )
2328122b058aSross                  && ( testFlags == float_flag_invalid )
2329122b058aSross                ) {
2330122b058aSross                 /* no problem */
2331122b058aSross             }
2332122b058aSross             else {
2333122b058aSross                 ++errorCount;
2334122b058aSross                 writeErrorFound( 10000 - count );
2335122b058aSross                 writeInput_a_float128();
2336122b058aSross                 fputs( "  ", stdout );
2337122b058aSross                 writeOutputs_z_int32( trueZ, trueFlags, testZ, testFlags );
2338122b058aSross                 fflush( stdout );
2339122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2340122b058aSross             }
2341122b058aSross         }
2342122b058aSross     }
2343122b058aSross  exit:
2344122b058aSross     writeTestsPerformed( 10000 - count );
2345122b058aSross 
2346122b058aSross }
2347122b058aSross 
2348122b058aSross #ifdef BITS64
2349122b058aSross 
2350122b058aSross void
test_a_float128_z_int64(int64 trueFunction (float128),int64 testFunction (float128))2351122b058aSross  test_a_float128_z_int64(
2352122b058aSross      int64 trueFunction( float128 ), int64 testFunction( float128 ) )
2353122b058aSross {
2354122b058aSross     int16 count;
2355122b058aSross     int64 trueZ, testZ;
2356122b058aSross     uint8 trueFlags, testFlags;
2357122b058aSross 
2358122b058aSross     errorCount = 0;
2359122b058aSross     tenthousandsCount = 0;
2360122b058aSross     count = 10000;
2361122b058aSross     testCases_initSequence( testCases_sequence_a_float128 );
2362122b058aSross     writeTestsTotal();
2363122b058aSross     while ( ! testCases_done || forever ) {
2364122b058aSross         testCases_next();
2365122b058aSross         *trueFlagsPtr = 0;
2366122b058aSross         trueZ = trueFunction( testCases_a_float128 );
2367122b058aSross         trueFlags = *trueFlagsPtr;
2368122b058aSross         (void) testFlagsFunctionPtr();
2369122b058aSross         testZ = testFunction( testCases_a_float128 );
2370122b058aSross         testFlags = testFlagsFunctionPtr();
2371122b058aSross         --count;
2372122b058aSross         if ( count == 0 ) {
2373122b058aSross             checkEarlyExit();
2374122b058aSross             count = 10000;
2375122b058aSross         }
2376122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2377122b058aSross             if (    ! checkNaNs
2378122b058aSross                  && float128_is_signaling_nan( testCases_a_float128 ) ) {
2379122b058aSross                 trueFlags |= float_flag_invalid;
2380122b058aSross             }
2381122b058aSross             if (    ( trueZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
2382122b058aSross                  && (    ( testZ == LIT64( 0x7FFFFFFFFFFFFFFF ) )
2383122b058aSross                       || ( testZ == (sbits64) LIT64( 0x8000000000000000 ) ) )
2384122b058aSross                  && ( trueFlags == float_flag_invalid )
2385122b058aSross                  && ( testFlags == float_flag_invalid )
2386122b058aSross                ) {
2387122b058aSross                 /* no problem */
2388122b058aSross             }
2389122b058aSross             else {
2390122b058aSross                 ++errorCount;
2391122b058aSross                 writeErrorFound( 10000 - count );
2392122b058aSross                 writeInput_a_float128();
2393122b058aSross                 fputs( "\n\t", stdout );
2394122b058aSross                 writeOutputs_z_int64( trueZ, trueFlags, testZ, testFlags );
2395122b058aSross                 fflush( stdout );
2396122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2397122b058aSross             }
2398122b058aSross         }
2399122b058aSross     }
2400122b058aSross  exit:
2401122b058aSross     writeTestsPerformed( 10000 - count );
2402122b058aSross 
2403122b058aSross }
2404122b058aSross 
2405122b058aSross #endif
2406122b058aSross 
2407122b058aSross void
test_a_float128_z_float32(float32 trueFunction (float128),float32 testFunction (float128))2408122b058aSross  test_a_float128_z_float32(
2409122b058aSross      float32 trueFunction( float128 ), float32 testFunction( float128 ) )
2410122b058aSross {
2411122b058aSross     int16 count;
2412122b058aSross     float32 trueZ, testZ;
2413122b058aSross     uint8 trueFlags, testFlags;
2414122b058aSross 
2415122b058aSross     errorCount = 0;
2416122b058aSross     tenthousandsCount = 0;
2417122b058aSross     count = 10000;
2418122b058aSross     testCases_initSequence( testCases_sequence_a_float128 );
2419122b058aSross     writeTestsTotal();
2420122b058aSross     while ( ! testCases_done || forever ) {
2421122b058aSross         testCases_next();
2422122b058aSross         *trueFlagsPtr = 0;
2423122b058aSross         trueZ = trueFunction( testCases_a_float128 );
2424122b058aSross         trueFlags = *trueFlagsPtr;
2425122b058aSross         (void) testFlagsFunctionPtr();
2426122b058aSross         testZ = testFunction( testCases_a_float128 );
2427122b058aSross         testFlags = testFlagsFunctionPtr();
2428122b058aSross         --count;
2429122b058aSross         if ( count == 0 ) {
2430122b058aSross             checkEarlyExit();
2431122b058aSross             count = 10000;
2432122b058aSross         }
2433122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2434122b058aSross             if (    ! checkNaNs
2435122b058aSross                  && float128_is_signaling_nan( testCases_a_float128 ) ) {
2436122b058aSross                 trueFlags |= float_flag_invalid;
2437122b058aSross             }
2438122b058aSross             if (    ! checkNaNs
2439122b058aSross                  && float32_isNaN( trueZ )
2440122b058aSross                  && float32_isNaN( testZ )
2441122b058aSross                  && ! float32_is_signaling_nan( testZ )
2442122b058aSross                  && ( trueFlags == testFlags )
2443122b058aSross                ) {
2444122b058aSross                 /* no problem */
2445122b058aSross             }
2446122b058aSross             else {
2447122b058aSross                 ++errorCount;
2448122b058aSross                 writeErrorFound( 10000 - count );
2449122b058aSross                 writeInput_a_float128();
2450122b058aSross                 fputs( "  ", stdout );
2451122b058aSross                 writeOutputs_z_float32( trueZ, trueFlags, testZ, testFlags );
2452122b058aSross                 fflush( stdout );
2453122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2454122b058aSross             }
2455122b058aSross         }
2456122b058aSross     }
2457122b058aSross  exit:
2458122b058aSross     writeTestsPerformed( 10000 - count );
2459122b058aSross 
2460122b058aSross }
2461122b058aSross 
2462122b058aSross void
test_a_float128_z_float64(float64 trueFunction (float128),float64 testFunction (float128))2463122b058aSross  test_a_float128_z_float64(
2464122b058aSross      float64 trueFunction( float128 ), float64 testFunction( float128 ) )
2465122b058aSross {
2466122b058aSross     int16 count;
2467122b058aSross     float64 trueZ, testZ;
2468122b058aSross     uint8 trueFlags, testFlags;
2469122b058aSross 
2470122b058aSross     errorCount = 0;
2471122b058aSross     tenthousandsCount = 0;
2472122b058aSross     count = 10000;
2473122b058aSross     testCases_initSequence( testCases_sequence_a_float128 );
2474122b058aSross     writeTestsTotal();
2475122b058aSross     while ( ! testCases_done || forever ) {
2476122b058aSross         testCases_next();
2477122b058aSross         *trueFlagsPtr = 0;
2478122b058aSross         trueZ = trueFunction( testCases_a_float128 );
2479122b058aSross         trueFlags = *trueFlagsPtr;
2480122b058aSross         (void) testFlagsFunctionPtr();
2481122b058aSross         testZ = testFunction( testCases_a_float128 );
2482122b058aSross         testFlags = testFlagsFunctionPtr();
2483122b058aSross         --count;
2484122b058aSross         if ( count == 0 ) {
2485122b058aSross             checkEarlyExit();
2486122b058aSross             count = 10000;
2487122b058aSross         }
2488122b058aSross         if ( ! float64_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2489122b058aSross             if (    ! checkNaNs
2490122b058aSross                  && float128_is_signaling_nan( testCases_a_float128 ) ) {
2491122b058aSross                 trueFlags |= float_flag_invalid;
2492122b058aSross             }
2493122b058aSross             if (    ! checkNaNs
2494122b058aSross                  && float64_isNaN( trueZ )
2495122b058aSross                  && float64_isNaN( testZ )
2496122b058aSross                  && ! float64_is_signaling_nan( testZ )
2497122b058aSross                  && ( trueFlags == testFlags )
2498122b058aSross                ) {
2499122b058aSross                 /* no problem */
2500122b058aSross             }
2501122b058aSross             else {
2502122b058aSross                 ++errorCount;
2503122b058aSross                 writeErrorFound( 10000 - count );
2504122b058aSross                 writeInput_a_float128();
2505122b058aSross                 fputs( "\n\t", stdout );
2506122b058aSross                 writeOutputs_z_float64( trueZ, trueFlags, testZ, testFlags );
2507122b058aSross                 fflush( stdout );
2508122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2509122b058aSross             }
2510122b058aSross         }
2511122b058aSross     }
2512122b058aSross  exit:
2513122b058aSross     writeTestsPerformed( 10000 - count );
2514122b058aSross 
2515122b058aSross }
2516122b058aSross 
2517122b058aSross #ifdef FLOATX80
2518122b058aSross 
2519122b058aSross void
test_a_float128_z_floatx80(floatx80 trueFunction (float128),floatx80 testFunction (float128))2520122b058aSross  test_a_float128_z_floatx80(
2521122b058aSross      floatx80 trueFunction( float128 ), floatx80 testFunction( float128 ) )
2522122b058aSross {
2523122b058aSross     int16 count;
2524122b058aSross     floatx80 trueZ, testZ;
2525122b058aSross     uint8 trueFlags, testFlags;
2526122b058aSross 
2527122b058aSross     errorCount = 0;
2528122b058aSross     tenthousandsCount = 0;
2529122b058aSross     count = 10000;
2530122b058aSross     testCases_initSequence( testCases_sequence_a_float128 );
2531122b058aSross     writeTestsTotal();
2532122b058aSross     while ( ! testCases_done || forever ) {
2533122b058aSross         testCases_next();
2534122b058aSross         *trueFlagsPtr = 0;
2535122b058aSross         trueZ = trueFunction( testCases_a_float128 );
2536122b058aSross         trueFlags = *trueFlagsPtr;
2537122b058aSross         (void) testFlagsFunctionPtr();
2538122b058aSross         testZ = testFunction( testCases_a_float128 );
2539122b058aSross         testFlags = testFlagsFunctionPtr();
2540122b058aSross         --count;
2541122b058aSross         if ( count == 0 ) {
2542122b058aSross             checkEarlyExit();
2543122b058aSross             count = 10000;
2544122b058aSross         }
2545122b058aSross         if ( ! floatx80_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2546122b058aSross             if (    ! checkNaNs
2547122b058aSross                  && float128_is_signaling_nan( testCases_a_float128 ) ) {
2548122b058aSross                 trueFlags |= float_flag_invalid;
2549122b058aSross             }
2550122b058aSross             if (    ! checkNaNs
2551122b058aSross                  && floatx80_isNaN( trueZ )
2552122b058aSross                  && floatx80_isNaN( testZ )
2553122b058aSross                  && ! floatx80_is_signaling_nan( testZ )
2554122b058aSross                  && ( trueFlags == testFlags )
2555122b058aSross                ) {
2556122b058aSross                 /* no problem */
2557122b058aSross             }
2558122b058aSross             else {
2559122b058aSross                 ++errorCount;
2560122b058aSross                 writeErrorFound( 10000 - count );
2561122b058aSross                 writeInput_a_float128();
2562122b058aSross                 fputs( "\n\t", stdout );
2563122b058aSross                 writeOutputs_z_floatx80( trueZ, trueFlags, testZ, testFlags );
2564122b058aSross                 fflush( stdout );
2565122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2566122b058aSross             }
2567122b058aSross         }
2568122b058aSross     }
2569122b058aSross  exit:
2570122b058aSross     writeTestsPerformed( 10000 - count );
2571122b058aSross 
2572122b058aSross }
2573122b058aSross 
2574122b058aSross #endif
2575122b058aSross 
2576122b058aSross void
test_az_float128(float128 trueFunction (float128),float128 testFunction (float128))2577122b058aSross  test_az_float128(
2578122b058aSross      float128 trueFunction( float128 ), float128 testFunction( float128 ) )
2579122b058aSross {
2580122b058aSross     int16 count;
2581122b058aSross     float128 trueZ, testZ;
2582122b058aSross     uint8 trueFlags, testFlags;
2583122b058aSross 
2584122b058aSross     errorCount = 0;
2585122b058aSross     tenthousandsCount = 0;
2586122b058aSross     count = 10000;
2587122b058aSross     testCases_initSequence( testCases_sequence_a_float128 );
2588122b058aSross     writeTestsTotal();
2589122b058aSross     while ( ! testCases_done || forever ) {
2590122b058aSross         testCases_next();
2591122b058aSross         *trueFlagsPtr = 0;
2592122b058aSross         trueZ = trueFunction( testCases_a_float128 );
2593122b058aSross         trueFlags = *trueFlagsPtr;
2594122b058aSross         (void) testFlagsFunctionPtr();
2595122b058aSross         testZ = testFunction( testCases_a_float128 );
2596122b058aSross         testFlags = testFlagsFunctionPtr();
2597122b058aSross         --count;
2598122b058aSross         if ( count == 0 ) {
2599122b058aSross             checkEarlyExit();
2600122b058aSross             count = 10000;
2601122b058aSross         }
2602122b058aSross         if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2603122b058aSross             if (    ! checkNaNs
2604122b058aSross                  && float128_is_signaling_nan( testCases_a_float128 ) ) {
2605122b058aSross                 trueFlags |= float_flag_invalid;
2606122b058aSross             }
2607122b058aSross             if (    ! checkNaNs
2608122b058aSross                  && float128_isNaN( trueZ )
2609122b058aSross                  && float128_isNaN( testZ )
2610122b058aSross                  && ! float128_is_signaling_nan( testZ )
2611122b058aSross                  && ( trueFlags == testFlags )
2612122b058aSross                ) {
2613122b058aSross                 /* no problem */
2614122b058aSross             }
2615122b058aSross             else {
2616122b058aSross                 ++errorCount;
2617122b058aSross                 writeErrorFound( 10000 - count );
2618122b058aSross                 writeInput_a_float128();
2619122b058aSross                 fputs( "\n\t", stdout );
2620122b058aSross                 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
2621122b058aSross                 fflush( stdout );
2622122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2623122b058aSross             }
2624122b058aSross         }
2625122b058aSross     }
2626122b058aSross  exit:
2627122b058aSross     writeTestsPerformed( 10000 - count );
2628122b058aSross 
2629122b058aSross }
2630122b058aSross 
2631122b058aSross void
test_ab_float128_z_flag(flag trueFunction (float128,float128),flag testFunction (float128,float128))2632122b058aSross  test_ab_float128_z_flag(
2633122b058aSross      flag trueFunction( float128, float128 ),
2634122b058aSross      flag testFunction( float128, float128 )
2635122b058aSross  )
2636122b058aSross {
2637122b058aSross     int16 count;
2638122b058aSross     flag trueZ, testZ;
2639122b058aSross     uint8 trueFlags, testFlags;
2640122b058aSross 
2641122b058aSross     errorCount = 0;
2642122b058aSross     tenthousandsCount = 0;
2643122b058aSross     count = 10000;
2644122b058aSross     testCases_initSequence( testCases_sequence_ab_float128 );
2645122b058aSross     writeTestsTotal();
2646122b058aSross     while ( ! testCases_done || forever ) {
2647122b058aSross         testCases_next();
2648122b058aSross         *trueFlagsPtr = 0;
2649122b058aSross         trueZ = trueFunction( testCases_a_float128, testCases_b_float128 );
2650122b058aSross         trueFlags = *trueFlagsPtr;
2651122b058aSross         (void) testFlagsFunctionPtr();
2652122b058aSross         testZ = testFunction( testCases_a_float128, testCases_b_float128 );
2653122b058aSross         testFlags = testFlagsFunctionPtr();
2654122b058aSross         --count;
2655122b058aSross         if ( count == 0 ) {
2656122b058aSross             checkEarlyExit();
2657122b058aSross             count = 10000;
2658122b058aSross         }
2659122b058aSross         if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2660122b058aSross             if (    ! checkNaNs
2661122b058aSross                  && (    float128_is_signaling_nan( testCases_a_float128 )
2662122b058aSross                       || float128_is_signaling_nan( testCases_b_float128 ) )
2663122b058aSross                ) {
2664122b058aSross                 trueFlags |= float_flag_invalid;
2665122b058aSross             }
2666122b058aSross             if ( ( trueZ != testZ ) || ( trueFlags != testFlags ) ) {
2667122b058aSross                 ++errorCount;
2668122b058aSross                 writeErrorFound( 10000 - count );
2669122b058aSross                 writeInputs_ab_float128();
2670122b058aSross                 fputs( "\n\t", stdout );
2671122b058aSross                 writeOutputs_z_flag( trueZ, trueFlags, testZ, testFlags );
2672122b058aSross                 fflush( stdout );
2673122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2674122b058aSross             }
2675122b058aSross         }
2676122b058aSross     }
2677122b058aSross  exit:
2678122b058aSross     writeTestsPerformed( 10000 - count );
2679122b058aSross     return;
2680122b058aSross 
2681122b058aSross }
2682122b058aSross 
2683122b058aSross void
test_abz_float128(float128 trueFunction (float128,float128),float128 testFunction (float128,float128))2684122b058aSross  test_abz_float128(
2685122b058aSross      float128 trueFunction( float128, float128 ),
2686122b058aSross      float128 testFunction( float128, float128 )
2687122b058aSross  )
2688122b058aSross {
2689122b058aSross     int16 count;
2690122b058aSross     float128 trueZ, testZ;
2691122b058aSross     uint8 trueFlags, testFlags;
2692122b058aSross 
2693122b058aSross     errorCount = 0;
2694122b058aSross     tenthousandsCount = 0;
2695122b058aSross     count = 10000;
2696122b058aSross     testCases_initSequence( testCases_sequence_ab_float128 );
2697122b058aSross     writeTestsTotal();
2698122b058aSross     while ( ! testCases_done || forever ) {
2699122b058aSross         testCases_next();
2700122b058aSross         *trueFlagsPtr = 0;
2701122b058aSross         trueZ = trueFunction( testCases_a_float128, testCases_b_float128 );
2702122b058aSross         trueFlags = *trueFlagsPtr;
2703122b058aSross         (void) testFlagsFunctionPtr();
2704122b058aSross         testZ = testFunction( testCases_a_float128, testCases_b_float128 );
2705122b058aSross         testFlags = testFlagsFunctionPtr();
2706122b058aSross         --count;
2707122b058aSross         if ( count == 0 ) {
2708122b058aSross             checkEarlyExit();
2709122b058aSross             count = 10000;
2710122b058aSross         }
2711122b058aSross         if ( ! float128_same( trueZ, testZ ) || ( trueFlags != testFlags ) ) {
2712122b058aSross             if (    ! checkNaNs
2713122b058aSross                  && (    float128_is_signaling_nan( testCases_a_float128 )
2714122b058aSross                       || float128_is_signaling_nan( testCases_b_float128 ) )
2715122b058aSross                ) {
2716122b058aSross                 trueFlags |= float_flag_invalid;
2717122b058aSross             }
2718122b058aSross             if (    ! checkNaNs
2719122b058aSross                  && float128_isNaN( trueZ )
2720122b058aSross                  && float128_isNaN( testZ )
2721122b058aSross                  && ! float128_is_signaling_nan( testZ )
2722122b058aSross                  && ( trueFlags == testFlags )
2723122b058aSross                ) {
2724122b058aSross                 /* no problem */
2725122b058aSross             }
2726122b058aSross             else {
2727122b058aSross                 ++errorCount;
2728122b058aSross                 writeErrorFound( 10000 - count );
2729122b058aSross                 writeInputs_ab_float128();
2730122b058aSross                 fputs( "\n\t", stdout );
2731122b058aSross                 writeOutputs_z_float128( trueZ, trueFlags, testZ, testFlags );
2732122b058aSross                 fflush( stdout );
2733122b058aSross                 if ( errorCount == maxErrorCount ) goto exit;
2734122b058aSross             }
2735122b058aSross         }
2736122b058aSross     }
2737122b058aSross  exit:
2738122b058aSross     writeTestsPerformed( 10000 - count );
2739122b058aSross     return;
2740122b058aSross 
2741122b058aSross }
2742122b058aSross 
2743122b058aSross #endif
2744122b058aSross 
2745