OSDN Git Service

PR c/39035
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / dfp / decfloat-constants.c
1 /* { dg-options "-std=gnu99" } */
2
3 /* N1150 4: Characteristics of decimal floating types <float.h>.
4    C99 5.2.4.2.2a[3]: New.
5
6    Verify constants about range of decimal float and three components of
7    decimal float defined in float.h.  */
8
9 /* Make sure we are exporting the right values to float.h. */
10 #ifndef __STDC_WANT_DEC_FP__
11 #define __STDC_WANT_DEC_FP__ 1
12 #endif
13
14 #include <float.h>
15
16 extern void abort (void);
17 static int failcnt;
18
19 /* Support compiling the test to report individual failures; default is
20    to abort as soon as a check fails.  */
21 #ifdef DBG
22 #include <stdio.h>
23 #define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
24 #else
25 #define FAILURE abort ();
26 #endif
27
28 int main ()
29 {
30   if (DEC32_MANT_DIG != 7) FAILURE
31   if (DEC64_MANT_DIG != 16) FAILURE
32   if (DEC128_MANT_DIG != 34) FAILURE
33
34   if (DEC32_MIN_EXP != -94) FAILURE
35   if (DEC64_MIN_EXP != -382) FAILURE
36   if (DEC128_MIN_EXP != -6142) FAILURE
37
38   if (DEC32_MAX_EXP != 97) FAILURE
39   if (DEC64_MAX_EXP != 385) FAILURE
40   if (DEC128_MAX_EXP != 6145) FAILURE
41
42   if (DEC32_MAX != 9.999999E96DF) FAILURE
43   if (DEC64_MAX != 9.999999999999999E384DD) FAILURE
44   if (DEC128_MAX != 9.999999999999999999999999999999999E6144DL) FAILURE
45
46   if (DEC32_EPSILON != 1E-6DF) FAILURE
47   if (DEC64_EPSILON != 1E-15DD) FAILURE
48   if (DEC128_EPSILON != 1E-33DL) FAILURE
49   
50   if (DEC32_MIN != 1E-95DF) FAILURE
51   if (DEC64_MIN != 1E-383DD) FAILURE
52   if (DEC128_MIN != 1E-6143DL) FAILURE
53
54   if (DEC32_SUBNORMAL_MIN != 0.000001E-95DF) FAILURE
55   if (DEC64_SUBNORMAL_MIN != 0.000000000000001E-383DD) FAILURE
56   if (DEC128_SUBNORMAL_MIN != 0.000000000000000000000000000000001E-6143DL)
57     FAILURE
58
59   if (failcnt != 0)
60     abort ();
61
62   return 0;
63 }