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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [dfp/] [usual-arith-conv.c] - Blame information for rev 823

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

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-options "-std=gnu99 -O0" } */
2
 
3
/* N1150 5.4: Usual arithmetic conversions.
4
   C99 6.3.1.8[1] (New).
5
 
6
   Test arithmetic operators with different decimal float types, and
7
   between decimal float types and integer types.  */
8
 
9
extern void abort (void);
10
static int failcnt = 0;
11
 
12
/* Support compiling the test to report individual failures; default is
13
   to abort as soon as a check fails.  */
14
#ifdef DBG
15
#include <stdio.h>
16
#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
17
#else
18
#define FAILURE abort ();
19
#endif
20
 
21
volatile _Decimal32 d32a, d32b, d32c;
22
volatile _Decimal64 d64a, d64b, d64c;
23
volatile _Decimal128 d128a, d128b, d128c;
24
volatile int i;
25
 
26
void
27
init ()
28
{
29
  d32b = 123.456e94df;
30
  d64b = 12.3456789012345e383dd;
31
  d128b = 12345.6789012345678901e4000dl;
32
 
33
  d32c = 1.3df;
34
  d64c = 1.2dd;
35
  d128c = 1.1dl;
36
 
37
  i = 2;
38
}
39
 
40
int
41
main ()
42
{
43
  init ();
44
 
45
  /* Usual arithmetic conversions between decimal float types; addition.  */
46
  d128a = d128b + d32b;
47
  if (d128a < d128b)
48
    FAILURE
49
  d128a = d32b + d128b;
50
  if (d128a < d128b)
51
    FAILURE
52
  d128a = d128b + d64b;
53
  if (d128a < d128b)
54
    FAILURE
55
  d128a = d64b + d128b;
56
  if (d128a < d128b)
57
    FAILURE
58
  d64a = d64b + d32b;
59
  if (d64a < d64b)
60
    FAILURE
61
  d64a = d32b + d64b;
62
  if (d64a < d64b)
63
    FAILURE
64
 
65
  /* Usual arithmetic conversions between decimal float types;
66
     multiplication.  */
67
  d128a = d128b * d32c;
68
  if (d128a < d128b)
69
    FAILURE
70
  d128a = d32c * d128b;
71
  if (d128a < d128b)
72
    FAILURE
73
  d128a = d128b * d64c;
74
  if (d128a < d128b)
75
    FAILURE
76
  d128a = d64c * d128b;
77
  if (d128a < d128b)
78
    FAILURE
79
  d64a = d64b * d32c;
80
  if (d64a < d64b)
81
    FAILURE
82
  d64a = d32c * d64b;
83
  if (d64a < d64b)
84
    FAILURE
85
 
86
  /* Usual arithmetic conversions between decimal float and integer types.  */
87
  d32a = d32c + i;
88
  if (d32a != d32c + 2.0df)
89
    FAILURE
90
  d32a = d32c - i;
91
  if (d32a != d32c - 2.0df)
92
    FAILURE
93
  d32a = i * d32c;
94
  if (d32a != d32c + d32c)
95
    FAILURE
96
  d32a = d32c / i;
97
  if (d32a != d32c / 2.0df)
98
    FAILURE
99
 
100
  d64a = i + d64c;
101
  if (d64a != d64c + 2.0dd)
102
    FAILURE
103
  d64a = d64c - i;
104
  if (d64a != d64c - 2.0dd)
105
    FAILURE
106
  d64a = d64c * i;
107
  if (d64a != d64c + d64c)
108
    FAILURE
109
  d64a = d64c / i;
110
  if (d64a != d64c / 2.0dd)
111
    FAILURE
112
 
113
  d128a = d128c + i;
114
  if (d128a != d128c + 2.0dl)
115
    FAILURE
116
  d128a = d128c - i;
117
  if (d128a != d128c - 2.0dl)
118
    FAILURE
119
  d128a = i * d128c;
120
  if (d128a != d128c + d128c)
121
    FAILURE
122
  d128a = d128c / i;
123
  if (d128a != d128c / 2.0dl)
124
    FAILURE
125
 
126
  return 0;
127
}

powered by: WebSVN 2.1.0

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