summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/gcn/fpdiv.c
blob: 936d39cf98e734c931d3f06354f15708da1e87d4 (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
/* { dg-do run } */

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

double num = 100;
double denom = 50;

union bits {
  double fp;
  uint64_t ull;
};

int main (int argc, char* argv[])
{
  union bits recip;
  union bits res;

  recip.fp = 1.0 / denom;

  if (recip.ull != 0x3f947ae147ae147b)
    {
      fprintf (stderr, "incorrectly-rounded reciprocal: %llx", recip.ull);
      exit (1);
    }

  res.fp = num / denom;

  if (res.ull != 0x4000000000000000)
    {
      fprintf (stderr, "incorrectly-rounded quotient: %llx", res.ull);
      exit (1);
    }

  return 0;
}