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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.dg/] [fnegate-1.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* Copyright (C) 2002 Free Software Foundation.
2
 
3
   Test floating point negation produces the expected results.
4
 
5
   Written by Roger Sayle, 21st May 2002.  */
6
 
7
/* { dg-do run } */
8
/* { dg-options "-O2 -ffast-math" } */
9
 
10
extern void abort ();
11
 
12
 
13
double
14
dneg (double x)
15
{
16
  return -x;
17
}
18
 
19
double
20
dmult (double x)
21
{
22
  return -1.0 * x;
23
}
24
 
25
double
26
ddiv (double x)
27
{
28
  return x / -1.0;
29
}
30
 
31
 
32
float
33
fneg (float x)
34
{
35
  return -x;
36
}
37
 
38
float
39
fmult (float x)
40
{
41
  return -1.0f * x;
42
}
43
 
44
float
45
fdiv (float x)
46
{
47
  return x / -1.0f;
48
}
49
 
50
 
51
void
52
ftest(float src, float dst)
53
{
54
  if (fneg (src) != dst)
55
    abort ();
56
 
57
  if (src != fneg (dst))
58
    abort ();
59
 
60
  if (fmult (src) != dst)
61
    abort ();
62
 
63
  if (src != fmult (dst))
64
    abort ();
65
 
66
  if (fdiv (src) != dst)
67
    abort ();
68
 
69
  if (src != fdiv(dst))
70
    abort ();
71
}
72
 
73
void
74
dtest(double src, double dst)
75
{
76
  if (dneg (src) != dst)
77
    abort ();
78
 
79
  if (src != dneg (dst))
80
    abort ();
81
 
82
  if (dmult (src) != dst)
83
    abort ();
84
 
85
  if (src != dmult (dst))
86
    abort ();
87
 
88
  if (ddiv (src) != dst)
89
    abort ();
90
 
91
  if (src != ddiv(dst))
92
    abort ();
93
}
94
 
95
 
96
int
97
main ()
98
{
99
  ftest (1.0f, -1.0f);
100
  ftest (2.0f, -2.0f);
101
  ftest (-3.0f, 3.0f);
102
  ftest (0.0f, -0.0f);
103
  ftest (-0.0f, 0.0f);
104
 
105
  dtest (1.0, -1.0);
106
  dtest (2.0, -2.0);
107
  dtest (-3.0, 3.0);
108
  dtest (0.0, -0.0);
109
  dtest (-0.0, 0.0);
110
 
111
  return 0;
112
}
113
 

powered by: WebSVN 2.1.0

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