1 /* Tests for _FloatN / _FloatNx types: compile and execution tests for
2    <float.h>.  Before including this file, define WIDTH as the value
3    N; define EXT to 1 for _FloatNx and 0 for _FloatN.  */
4 
5 #define __STDC_WANT_IEC_60559_TYPES_EXT__
6 #include <float.h>
7 
8 #define CONCATX(X, Y) X ## Y
9 #define CONCAT(X, Y) CONCATX (X, Y)
10 #define CONCAT3(X, Y, Z) CONCAT (CONCAT (X, Y), Z)
11 #define CONCAT4(W, X, Y, Z) CONCAT (CONCAT (CONCAT (W, X), Y), Z)
12 
13 #if EXT
14 # define TYPE CONCAT3 (_Float, WIDTH, x)
15 # define CST(C) CONCAT4 (C, f, WIDTH, x)
16 # define FMAC(M) CONCAT4 (FLT, WIDTH, X_, M)
17 #else
18 # define TYPE CONCAT (_Float, WIDTH)
19 # define CST(C) CONCAT3 (C, f, WIDTH)
20 # define FMAC(M) CONCAT4 (FLT, WIDTH, _, M)
21 #endif
22 
23 extern void exit (int);
24 extern void abort (void);
25 
26 int
main(void)27 main (void)
28 {
29   volatile TYPE a = CST (1.0);
30   for (int i = 0; i >= FMAC (MIN_EXP); i--)
31     a *= CST (0.5);
32   if (a != FMAC (MIN))
33     abort ();
34   for (int i = 0; i < FMAC (MANT_DIG) - 1; i++)
35     a *= CST (0.5);
36   if (a != FMAC (TRUE_MIN))
37     abort ();
38   a *= CST (0.5);
39   if (a != CST (0.0))
40     abort ();
41   a = FMAC (EPSILON);
42   for (int i = 0; i < FMAC (MANT_DIG) - 1; i++)
43     a *= CST (2.0);
44   if (a != CST (1.0))
45     abort ();
46   a = FMAC (MAX);
47   for (int i = 0; i < FMAC (MAX_EXP); i++)
48     a *= CST (0.5);
49   if (a != CST (1.0) - FMAC (EPSILON) * CST (0.5))
50     abort ();
51   exit (0);
52 }
53