1/* N1150 5.2 Conversions among decimal floating types and between 2 decimal floating types and generic floating types. 3 C99 6.3.1.5(4) Conversions, arithmetic operands, real floating types. */ 4 5/* Long double isn't supported yet at runtime, so disable those checks. */ 6 7#include "dfp-dbg.h" 8 9static int skip_long_double; 10 11volatile _Decimal32 d32; 12volatile _Decimal64 d64; 13volatile _Decimal128 d128; 14volatile float sf; 15volatile double df; 16volatile long double tf; 17 18int 19main () 20{ 21 /* Conversions from decimal float to binary float. */ 22 23 if (sizeof (long double) == sizeof (double)) 24 skip_long_double = 1; 25 26 /* Conversions from _Decimal32. */ 27 d32 = 2.0df; 28 sf = d32; 29 if (sf != 2.0f) 30 FAILURE 31 32 df = d32; 33 if (df != 2.0) 34 FAILURE 35 36 if (skip_long_double == 0) 37 { 38 tf = d32; 39 if (tf != 2.0l) 40 FAILURE 41 } 42 43 /* Conversions from _Decimal64. */ 44 d64 = -7.0dd; 45 sf = d64; 46 if (sf != -7.0f) 47 FAILURE 48 49 df = d64; 50 if (df != -7.0) 51 FAILURE 52 53 if (skip_long_double == 0) 54 { 55 tf = d64; 56 if (tf != -7.0l) 57 FAILURE 58 } 59 60 /* Conversions from _Decimal128. */ 61 d128 = 30.0dl; 62 sf = d128; 63 if (sf != 30.0f) 64 FAILURE 65 66 df = d128; 67 if (df != 30.0) 68 FAILURE 69 70 df = d128; 71 if (df != 30.0l) 72 FAILURE 73 74 /* Conversions from binary float to decimal float. */ 75 sf = 30.0f; 76 d32 = sf; 77 if (d32 != 30.0df) 78 FAILURE 79 80 d64 = sf; 81 if (d64 != 30.0dd) 82 FAILURE 83 84 df = -2.0; 85 d32 = df; 86 if (d32 != -2.0df) 87 FAILURE 88 89 d64 = df; 90 if (d64 != -2.0dd) 91 FAILURE 92 93 d128 = df; 94 if (d128 != -2.0dl) 95 FAILURE 96 97 sf = 30.0f; 98 d128 = sf; 99 if (d128 != 30.0dl) 100 FAILURE 101 102 if (skip_long_double == 0) 103 { 104 tf = -22.0l; 105 d32 = tf; 106 if (d32 != -22.0df) 107 FAILURE 108 109 d64 = tf; 110 if (d64 != -22.0dd) 111 FAILURE 112 113 d128 = tf; 114 if (d128 != -22.0dl) 115 FAILURE 116 } 117 118 /* 2**(-11) = 0.00048828125. */ 119 d128 = 0.000488281251dl; 120 sf = d128; 121 if (sf != 0.00048828125f) 122 FAILURE 123 /* 2**(-25) = 0.298023223876953125E-7. */ 124 d128 = 2.98023223876953125E-8dl; 125 df = d128; 126 if (df < (2.9802322387695312e-08 - 0.00000000001) 127 || df > (2.9802322387695312e-08 + 0.00000000001)) 128 FAILURE 129 130 FINISH 131} 132