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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [dfp/] [convert-dfp-round.c] - Blame information for rev 298

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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