OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [dfp/] [convert-complex.c] - Blame information for rev 149

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

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-options "-O3" } */
2
 
3
/* N1150 5.3 Conversions between decimal floating and complex.
4
   C99 6.3.1.7 Conversions, arithmetic operands, real and complex.  */
5
 
6
extern void abort(void);
7
static int failcnt;
8
 
9
/* Support compiling the test to report individual failures; default is
10
   to abort as soon as a check fails.  */
11
#ifdef DBG
12
#include <stdio.h>
13
#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
14
#else
15
#define FAILURE abort ();
16
#endif
17
 
18
int
19
main ()
20
{
21
  _Complex float cf;
22
  _Complex double cd;
23
  _Complex long double cld;
24
 
25
  _Decimal32 d32;
26
  _Decimal64 d64;
27
  _Decimal128 d128;
28
 
29
  cf = 2.0f *  __extension__ 1i + 3.0f;
30
  cd = 2.0 * __extension__ 1i + 3.0;
31
  cld = 2.0l * __extension__ 1i + 3.0l;
32
 
33
  /* Convert complex to decimal floating.  */
34
  d32 = cf;
35
  d64 = cd;
36
  d128 = cld;
37
 
38
  if (d32 != 3.0DF)
39
    FAILURE
40
  if (d64 != 3.0dd)
41
    FAILURE
42
  if (d128 != 3.0dl)
43
    FAILURE
44
 
45
  /* Convert decimal floating to complex.  */
46
  d32 = 2.5DF;
47
  d64 = 1.5DD;
48
  d128 = 2.5DL;
49
 
50
  cf = d32;
51
  cd = d64;
52
  cld = d128;
53
 
54
  /* N1107 5.3 Conversions between decimal floating and complex.
55
     When a value of decimal floating type converted to a complex
56
     type, the real part of the complex result value is undermined
57
     by the rules of conversions in N1107 5.2 and the imaginary part
58
     of the complex result value is zero.  */
59
 
60
  if (__real__ cf != 2.5f)
61
    FAILURE
62
  if (__real__ cd !=1.5)
63
    FAILURE
64
  if (__real__ cld !=  2.5)
65
    FAILURE
66
  if (__imag__ cf != 0.0f)
67
    FAILURE
68
  if (__imag__ cd != 0.0)
69
    FAILURE
70
  if (__imag__ cld != 0.0l)
71
    FAILURE
72
 
73
  /*  Verify that the conversions from DFP types to complex is
74
      determined by the rules of conversion to the real part.  */
75
 
76
  /*  Convert _Decimal64 to _Complex float.  */
77
  d64 = 0.125dl;
78
  cf = d64;
79
  if (__real__ cf != 0.125f)
80
    FAILURE
81
  /*  Convert _Decimal128 to _Complex double.  */
82
  d128 = 1.25E-7dl;
83
  cd = d128;
84
  if (__real__ cd != 1.25E-7)
85
    FAILURE
86
 
87
  /*  Verify that conversion from complex to decimal floating types
88
      results in the value of the real part converted to the result
89
      type according to the rules of conversion between those types.  */
90
 
91
  /*  Convert _Complex float to decimal float types.  */
92
  cf = 2.0f *  __extension__ 1i + 2.25f;
93
  d32 = cf;
94
  d64 = cf;
95
  d128 = cf;
96
  if (d32 != 2.25DF)
97
    FAILURE
98
  if (d64 != 2.25DD)
99
    FAILURE
100
  if (d128 != 2.25DL)
101
    FAILURE
102
 
103
  /*  Convert _Complex double to decimal float types.  */
104
  cd = 2.0 *  __extension__ 1i + 1.25;
105
  d32 = cd;
106
  d64 = cd;
107
  d128 = cd;
108
  if (d32 != 1.25DF)
109
    FAILURE
110
  if (d64 != 1.25DD)
111
    FAILURE
112
  if (d128 != 1.25DL)
113
    FAILURE
114
 
115
  /*  Convert _Complex long double to decimal float types.  */
116
  cld = 2.0l *  __extension__ 1i + 0.0625l;
117
  d32 = cld;
118
  d64 = cld;
119
  d128 = cld;
120
  if (d32 != 0.0625DF)
121
    FAILURE
122
  if (d64 != 0.0625DD)
123
    FAILURE
124
  if (d128 != 0.0625DL)
125
    FAILURE
126
 
127
  return 0;
128
}

powered by: WebSVN 2.1.0

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