summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/ieee/rbug.c
blob: 1586bd7d43ba3361cafbddd8c95f23c50df8e350 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#if defined(__i386__) && defined(__FreeBSD__)
#include <ieeefp.h>
#endif

double d (unsigned long long k)
{
  double x;

  x = (double) k;
  return x;
}

float s (unsigned long long k)
{
  float x;

  x = (float) k;
  return x;
}

main ()
{
  unsigned long long int k;
  double x;

#if defined(__i386__) && defined(__FreeBSD__)
  /* This test case assumes extended-precision, but FreeBSD defaults to
     double-precision.  Make it so.  */
  fpsetprec (FP_PE);
#endif

  if (sizeof (double) >= 8)
    {
      k = 0x8693ba6d7d220401ULL;
      x = d (k);
      k = (unsigned long long) x;
      if (k != 0x8693ba6d7d220800ULL)
	abort ();
    }

  k = 0x8234508000000001ULL;
  x = s (k);
  k = (unsigned long long) x;
#ifdef __SPU__
  /* SPU float rounds towards zero.  */
  if (k != 0x8234500000000000ULL)
    abort ();
#else
  if (k != 0x8234510000000000ULL)
    abort ();
#endif

  exit (0);
}