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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [c-c++-common/] [dfp/] [convert-dfp.c] - Blame information for rev 686

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 686 jeremybenn
/* { dg-options "-O0" } */
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
   Test various conversions involving decimal floating types. */
8
 
9
#ifndef __STDC_WANT_DEC_FP__
10
#define __STDC_WANT_DEC_FP__ 1
11
#endif
12
 
13
#include "dfp-dbg.h"
14
#include <float.h>
15
 
16
volatile _Decimal32 d32;
17
volatile _Decimal64 d64;
18
volatile _Decimal128 d128;
19
 
20
int
21
main ()
22
{
23
  /* Conversions to larger types.  */
24
  d32 = 123.4df;
25
  d64 = d32;
26
  if (d64 != 123.4dd)
27
    FAILURE
28
  d128 = d32;
29
  if (d128 != 123.4dl)
30
    FAILURE
31
  d64 = 345.678dd;
32
  d128 = d64;
33
  if (d128 != 345.678dl)
34
    FAILURE
35
 
36
  /* Conversions to smaller types for which the value fits.  */
37
  d64 = 3456.789dd;
38
  d32 = d64;
39
  if (d32 != 3456.789df)
40
    FAILURE
41
  d128 = 123.4567dl;
42
  d32 = d128;
43
  if (d32 != 123.4567df)
44
    FAILURE
45
 
46
  d128 = 1234567890.123456dl;
47
  d64 = d128;
48
  if (d64 != 1234567890.123456dd)
49
    FAILURE
50
 
51
  /* Test demotion to non-representable decimal floating type. */
52
 
53
  /* Assumes a default rounding mode of 'near'.  This uses the rules
54
     describe in the 27 July 2005 draft of IEEE 754r, which are much
55
     more clear that what's described in draft 5 of N1107.  */
56
 
57
  /* Rounds to what _Decimal32 can handle.  */
58
  d64 = 9.99999949E96DD;
59
  d32 = d64;
60
  if (d32 != DEC32_MAX)
61
    FAILURE
62
 
63
  /* Rounds to more than _Decimal32 can handle.  */
64
  d64 = 9.9999995E96DD;
65
  d32 = d64;
66
  if (d32 != __builtin_infd32())
67
    FAILURE
68
 
69
  /* Rounds to what _Decimal32 can handle.  */
70
  d128 = 9.99999949E96DD;
71
  d32 = d128;
72
  if (d32 != DEC32_MAX)
73
    FAILURE
74
 
75
  /* Rounds to more than _Decimal32 can handle.  */
76
  d128= 9.9999995E96DD;
77
  d32 = d128;
78
  if (d32 != __builtin_infd32())
79
    FAILURE
80
 
81
  /* Rounds to what _Decimal64 can handle.  */
82
  d128 = 9.99999999999999949E384DL;
83
  d64 = d128;
84
  if (d64 != DEC64_MAX)
85
    FAILURE
86
 
87
  /* Rounds to more than _Decimal64 can handle.  */
88
  d128 = 9.9999999999999995E384DL;
89
  d64 = d128;
90
  if (d64 != __builtin_infd64())
91
    FAILURE
92
 
93
  FINISH
94
}

powered by: WebSVN 2.1.0

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