OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [ieee/] [mzero2.c] - Blame information for rev 825

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Test IEEE +0/-0 rules */
2
 
3
static double pzero = +0.0;
4
static double nzero = -0.0;
5
static double pinf  = +1.0 / 0.0;
6
static double ninf  = -1.0 / 0.0;
7
static double nan   =  0.0 / 0.0;
8
 
9
void
10
expect (double value, double expected)
11
{
12
  if (expected != expected)     /* expected value is Not a number */
13
    {
14
      if (value == value)       /* actual value is a number */
15
        abort ();
16
    }
17
 
18
  else if (value != value)
19
    abort ();                   /* actual value is a NaN */
20
 
21
  else if (memcmp ((void *)&value, (void *)&expected, sizeof (double)) != 0)
22
    abort ();                   /* values don't match */
23
}
24
 
25
main ()
26
{
27
  expect (pzero + pzero, pzero);
28
  expect (pzero + nzero, pzero);
29
  expect (nzero + pzero, pzero);
30
  expect (nzero + nzero, nzero);
31
 
32
  expect (pzero - pzero, pzero);
33
  expect (pzero - nzero, pzero);
34
  expect (nzero - pzero, nzero);
35
  expect (nzero - nzero, pzero);
36
 
37
  expect (pzero * pzero, pzero);
38
  expect (pzero * nzero, nzero);
39
  expect (nzero * pzero, nzero);
40
  expect (nzero * nzero, pzero);
41
 
42
  expect (+1.00 * pzero, pzero);
43
  expect (-1.00 * pzero, nzero);
44
  expect (+1.00 * nzero, nzero);
45
  expect (-1.00 * nzero, pzero);
46
 
47
  expect (pzero / pzero, nan);
48
  expect (pzero / nzero, nan);
49
  expect (nzero / pzero, nan);
50
  expect (nzero / nzero, nan);
51
 
52
  expect (+1.00 / pzero, pinf);
53
  expect (-1.00 / pzero, ninf);
54
  expect (+1.00 / nzero, ninf);
55
  expect (-1.00 / nzero, pinf);
56
 
57
  exit (0);
58
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.