OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [apps/] [testfloat/] [testLoops.c] - Blame information for rev 425

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.