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/] [convert-dfp-round.c] - Blame information for rev 853

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

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-options "-O0 -std=gnu99" } */
2
 
3
/* N1150 5.2: Conversions among decimal floating types and between
4
   decimal floating types and generic floating types.
5
   C99 6.3.1.5(3) New.
6
 
7
   Perform conversions between DFP types in which the assigned value
8
   cannot be represented exactly in the result and must be rounded
9
   correctly according to the current rounding mode.
10
 
11
   Normally this would not be part of compiler testing, but conversions
12
   are currently handled in libgcc via decNumber.  */
13
 
14
#include "dfp-round.h"
15
 
16
extern void abort (void);
17
static int failcnt = 0;
18
 
19
/* Support compiling the test to report individual failures; default is
20
   to abort as soon as a check fails.  */
21
#ifdef DBG
22
#include <stdio.h>
23
#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
24
#else
25
#define FAILURE abort ();
26
#endif
27
 
28
_Decimal32 d32;
29
_Decimal64 d64;
30
_Decimal128 d128;
31
 
32
_Decimal32 d64_to_d32 (_Decimal64 d) { return d; }
33
_Decimal64 d128_to_d64 (_Decimal128 d) { return d; }
34
_Decimal32 d128_to_d32 (_Decimal128 d) { return d; }
35
 
36
int
37
do_d64_to_d32 (_Decimal64 orig, _Decimal32 exp)
38
{
39
  d64 = orig;
40
  d32 = d64_to_d32 (d64);
41
  return (d32 == exp);
42
}
43
 
44
int
45
do_d128_to_d32 (_Decimal128 orig, _Decimal32 exp)
46
{
47
  d128 = orig;
48
  d32 = d128_to_d32 (d128);
49
  return (d32 == exp);
50
}
51
 
52
int
53
do_d128_to_d64 (_Decimal128 orig, _Decimal64 exp)
54
{
55
  d128 = orig;
56
  d64 = d128_to_d64 (d128);
57
  return (d64 == exp);
58
}
59
 
60
int
61
main ()
62
{
63
  DFP_SETROUND (FE_DEC_DOWNWARD);
64
  if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE
65
  if (!do_d64_to_d32 (1.1111135dd, 1.111113df)) FAILURE
66
  if (!do_d64_to_d32 (-1.1111125dd, -1.111113df)) FAILURE
67
  if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE
68
  if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE
69
  if (!do_d128_to_d32 (1.1111135dl, 1.111113df)) FAILURE
70
  if (!do_d128_to_d32 (-1.1111125dl, -1.111113df)) FAILURE
71
  if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE
72
  if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE
73
  if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111113dd)) FAILURE
74
  if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111113dd)) FAILURE
75
  if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE
76
 
77
  DFP_SETROUND (FE_DEC_TONEAREST);
78
  if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE
79
  if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE
80
  if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE
81
  if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE
82
  if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE
83
  if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE
84
  if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE
85
  if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE
86
  if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE
87
  if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE
88
  if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE
89
  if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE
90
 
91
  DFP_SETROUND (FE_DEC_TONEARESTFROMZERO);
92
  if (!do_d64_to_d32 (1.1111125dd, 1.111113df)) FAILURE
93
  if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE
94
  if (!do_d64_to_d32 (-1.1111125dd, -1.111113df)) FAILURE
95
  if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE
96
  if (!do_d128_to_d32 (1.1111125dl, 1.111113df)) FAILURE
97
  if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE
98
  if (!do_d128_to_d32 (-1.1111125dl, -1.111113df)) FAILURE
99
  if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE
100
  if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111113dd)) FAILURE
101
  if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE
102
  if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111113dd)) FAILURE
103
  if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE
104
 
105
  DFP_SETROUND (FE_DEC_TOWARDZERO);
106
  if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE
107
  if (!do_d64_to_d32 (1.1111135dd, 1.111113df)) FAILURE
108
  if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE
109
  if (!do_d64_to_d32 (-1.1111135dd, -1.111113df)) FAILURE
110
  if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE
111
  if (!do_d128_to_d32 (1.1111135dl, 1.111113df)) FAILURE
112
  if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE
113
  if (!do_d128_to_d32 (-1.1111135dl, -1.111113df)) FAILURE
114
  if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE
115
  if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111113dd)) FAILURE
116
  if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE
117
  if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111113dd)) FAILURE
118
 
119
  DFP_SETROUND (FE_DEC_UPWARD);
120
  if (!do_d64_to_d32 (1.1111125dd, 1.111113df)) FAILURE
121
  if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE
122
  if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE
123
  if (!do_d64_to_d32 (-1.1111135dd, -1.111113df)) FAILURE
124
  if (!do_d128_to_d32 (1.1111125dl, 1.111113df)) FAILURE
125
  if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE
126
  if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE
127
  if (!do_d128_to_d32 (-1.1111135dl, -1.111113df)) FAILURE
128
  if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111113dd)) FAILURE
129
  if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE
130
  if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE
131
  if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111113dd)) FAILURE
132
 
133
  if (failcnt)
134
    abort ();
135
  return 0;
136
}

powered by: WebSVN 2.1.0

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