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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [ieee/] [mul-subnormal-single-1.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* Check that certain subnormal numbers (formerly known as denormalized
2
   numbers) are rounded to within 0.5 ulp.  PR other/14354.  */
3
 
4
/* This test requires that float and unsigned int are the same size and
5
   that the sign-bit of the float is at MSB of the unsigned int.  */
6
 
7
#if __INT_MAX__ != 2147483647L
8
int main () { exit (0); }
9
#else
10
 
11
union uf
12
{
13
  unsigned int u;
14
  float f;
15
};
16
 
17
static float
18
u2f (unsigned int v)
19
{
20
  union uf u;
21
  u.u = v;
22
  return u.f;
23
}
24
 
25
static unsigned int
26
f2u (float v)
27
{
28
  union uf u;
29
  u.f = v;
30
  return u.u;
31
}
32
 
33
int ok = 1;
34
 
35
static void
36
tstmul (unsigned int ux, unsigned int uy, unsigned int ur)
37
{
38
  float x = u2f (ux);
39
  float y = u2f (uy);
40
 
41
  if (f2u (x * y) != ur)
42
    /* Set a variable rather than aborting here, to simplify tracing when
43
       several computations are wrong.  */
44
    ok = 0;
45
}
46
 
47
/* We don't want to make this const and static, or else we risk inlining
48
   causing the test to fold as constants at compile-time.  */
49
struct
50
{
51
  unsigned int p1, p2, res;
52
} expected[] =
53
  {
54
    {0xfff, 0x3f800400, 0xfff},
55
    {0xf, 0x3fc88888, 0x17},
56
    {0xf, 0x3f844444, 0xf}
57
  };
58
 
59
int
60
main (int argc, char *argv[], char *envp[])
61
{
62
  unsigned int i;
63
 
64
  for (i = 0; i < sizeof (expected) / sizeof (expected[0]); i++)
65
    {
66
      tstmul (expected[i].p1, expected[i].p2, expected[i].res);
67
      tstmul (expected[i].p2, expected[i].p1, expected[i].res);
68
    }
69
 
70
  if (!ok)
71
    abort ();
72
 
73
  exit (0);
74
}
75
#endif

powered by: WebSVN 2.1.0

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