Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.target / arm / fp16-rounding-alt-1.c
blob27bb40dcfee837587e79af6e2be90290a572c06f
1 /* Test that rounding double to __fp16 happens directly, using an example
2 of a number that would round differently if it went from double to
3 __fp16 via float. */
5 /* { dg-do run } */
6 /* { dg-require-effective-target arm_fp16_alternative_ok } */
7 /* { dg-options "-mfp16-format=alternative" } */
9 #include <stdlib.h>
11 /* The original double value. */
12 #define ORIG 0x1.0020008p0
14 /* The expected (double)((__fp16)ORIG) value. */
15 #define ROUNDED 0x1.0040000p0
17 typedef union u {
18 __fp16 f;
19 unsigned short h;
20 } ufh;
22 ufh s = { ORIG };
23 ufh r = { ROUNDED };
25 double d = ORIG;
27 int
28 main (void)
30 ufh x;
32 /* Test that the rounding is correct for static initializers. */
33 if (s.h != r.h)
34 abort ();
36 /* Test that the rounding is correct for a casted constant expression
37 not in a static initializer. */
38 x.f = (__fp16)ORIG;
39 if (x.h != r.h)
40 abort ();
42 /* Test that the rounding is correct for a runtime conversion. */
43 x.f = (__fp16)d;
44 if (x.h != r.h)
45 abort ();
47 return 0;