Corrected date in changelog
[official-gcc.git] / gcc / testsuite / gcc.dg / 20020607-2.c
blob239aa9b388055d64529958d5baf192c8e64d6437
1 /* Copyright (C) 2002 Free Software Foundation.
3 Test for correctness of floating point comparisons.
5 Written by Roger Sayle, 3rd June 2002. */
7 /* { dg-do run } */
8 /* { dg-options "-O2 -ffast-math" } */
10 extern void abort (void);
12 int test1 (double x, int ok)
14 if ((x - 1.0) > 0.0)
16 if (!ok) abort ();
18 else
19 if (ok) abort ();
22 int test1f (float x, int ok)
24 if ((x - 1.0f) > 0.0f)
26 if (!ok) abort ();
28 else
29 if (ok) abort ();
32 int test2 (double x, int ok)
34 if ((x + 1.0) < 0.0)
36 if (!ok) abort ();
38 else
39 if (ok) abort ();
42 int test2f (float x, int ok)
44 if ((x + 1.0f) < 0.0f)
46 if (!ok) abort ();
48 else
49 if (ok) abort ();
53 int
54 main ()
56 test1 (-2.0, 0);
57 test1 ( 0.0, 0);
58 test1 ( 2.0, 1);
60 test1f (-2.0f, 0);
61 test1f ( 0.0f, 0);
62 test1f ( 2.0f, 1);
64 test2 (-2.0, 1);
65 test2 ( 0.0, 0);
66 test2 ( 2.0, 0);
68 test2f (-2.0f, 1);
69 test2f ( 0.0f, 0);
70 test2f ( 2.0f, 0);
72 return 0;