2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / ieee / fp-cmp-4.c
blob45527a23aff6ce6836a75bd70cb189f282f05a74
1 void
2 test_isunordered(double x, double y, int true)
4 if (__builtin_isunordered(x, y))
6 if (! true)
7 abort ();
9 else
11 if (true)
12 abort ();
16 void
17 test_isless(double x, double y, int true)
19 if (__builtin_isless(x, y))
21 if (! true)
22 abort ();
24 else
26 if (true)
27 abort ();
31 void
32 test_islessequal(double x, double y, int true)
34 if (__builtin_islessequal(x, y))
36 if (! true)
37 abort ();
39 else
41 if (true)
42 abort ();
46 void
47 test_isgreater(double x, double y, int true)
49 if (__builtin_isgreater(x, y))
51 if (! true)
52 abort ();
54 else
56 if (true)
57 abort ();
61 void
62 test_isgreaterequal(double x, double y, int true)
64 if (__builtin_isgreaterequal(x, y))
66 if (! true)
67 abort ();
69 else
71 if (true)
72 abort ();
76 void
77 test_islessgreater(double x, double y, int true)
79 if (__builtin_islessgreater(x, y))
81 if (! true)
82 abort ();
84 else
86 if (true)
87 abort ();
91 #define NAN (0.0 / 0.0)
93 int
94 main()
96 struct try
98 double x, y;
99 unsigned unord : 1;
100 unsigned lt : 1;
101 unsigned le : 1;
102 unsigned gt : 1;
103 unsigned ge : 1;
104 unsigned lg : 1;
107 static struct try const data[] =
109 { NAN, NAN, 1, 0, 0, 0, 0, 0 },
110 { 0.0, NAN, 1, 0, 0, 0, 0, 0 },
111 { NAN, 0.0, 1, 0, 0, 0, 0, 0 },
112 { 0.0, 0.0, 0, 0, 1, 0, 1, 0 },
113 { 1.0, 2.0, 0, 1, 1, 0, 0, 1 },
114 { 2.0, 1.0, 0, 0, 0, 1, 1, 1 },
117 const int n = sizeof(data) / sizeof(data[0]);
118 int i;
120 for (i = 0; i < n; ++i)
122 test_isunordered (data[i].x, data[i].y, data[i].unord);
123 test_isless (data[i].x, data[i].y, data[i].lt);
124 test_islessequal (data[i].x, data[i].y, data[i].le);
125 test_isgreater (data[i].x, data[i].y, data[i].gt);
126 test_isgreaterequal (data[i].x, data[i].y, data[i].ge);
127 test_islessgreater (data[i].x, data[i].y, data[i].lg);
130 exit (0);