2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / ieee / mzero4.c
blob0ede7ec959870754c934a519ed25d0a6c57fc712
1 /* Copyright (C) 2003 Free Software Foundation.
2 by Roger Sayle <roger@eyesopen.com>, derived from mzero3.c
4 Constant folding of sin(-0.0), tan(-0.0) and atan(-0.0) should
5 all return -0.0, for both double and float forms. */
7 void abort (void);
8 typedef __SIZE_TYPE__ size_t;
9 extern int memcmp (const void *, const void *, size_t);
11 double sin (double);
12 double tan (double);
13 double atan (double);
15 float sinf (float);
16 float tanf (float);
17 float atanf (float);
19 void expectd (double, double);
20 void expectf (float, float);
22 void
23 expectd (double value, double expected)
25 if (value != expected
26 || memcmp ((void *)&value, (void *) &expected, sizeof (double)) != 0)
27 abort ();
30 void
31 expectf (float value, float expected)
33 if (value != expected
34 || memcmp ((void *)&value, (void *) &expected, sizeof (float)) != 0)
35 abort ();
38 int main ()
40 expectd (sin (0.0), 0.0);
41 expectd (tan (0.0), 0.0);
42 expectd (atan (0.0), 0.0);
44 expectd (sin (-0.0), -0.0);
45 expectd (tan (-0.0), -0.0);
46 expectd (atan (-0.0), -0.0);
48 expectf (sinf (0.0f), 0.0f);
49 expectf (tanf (0.0f), 0.0f);
50 expectf (atanf (0.0f), 0.0f);
52 expectf (sinf (-0.0f), -0.0f);
53 expectf (tanf (-0.0f), -0.0f);
54 expectf (atanf (-0.0f), -0.0f);
56 return 0;