1 /* { dg-options "-O3" } */ 2 3 /* N1150 5.3 Conversions between decimal floating and complex. 4 C99 6.3.1.7 Conversions, arithmetic operands, real and complex. */ 5 6 #include "dfp-dbg.h" 7 8 int main()9main () 10 { 11 _Complex float cf; 12 _Complex double cd; 13 _Complex long double cld; 14 15 _Decimal32 d32; 16 _Decimal64 d64; 17 _Decimal128 d128; 18 19 cf = 2.0f * __extension__ 1i + 3.0f; 20 cd = 2.0 * __extension__ 1i + 3.0; 21 cld = 2.0l * __extension__ 1i + 3.0l; 22 23 /* Convert complex to decimal floating. */ 24 d32 = cf; 25 d64 = cd; 26 d128 = cld; 27 28 if (d32 != 3.0DF) 29 FAILURE 30 if (d64 != 3.0dd) 31 FAILURE 32 if (d128 != 3.0dl) 33 FAILURE 34 35 /* Convert decimal floating to complex. */ 36 d32 = 2.5DF; 37 d64 = 1.5DD; 38 d128 = 2.5DL; 39 40 cf = d32; 41 cd = d64; 42 cld = d128; 43 44 /* N1107 5.3 Conversions between decimal floating and complex. 45 When a value of decimal floating type converted to a complex 46 type, the real part of the complex result value is undermined 47 by the rules of conversions in N1107 5.2 and the imaginary part 48 of the complex result value is zero. */ 49 50 if (__real__ cf != 2.5f) 51 FAILURE 52 if (__real__ cd !=1.5) 53 FAILURE 54 if (__real__ cld != 2.5) 55 FAILURE 56 if (__imag__ cf != 0.0f) 57 FAILURE 58 if (__imag__ cd != 0.0) 59 FAILURE 60 if (__imag__ cld != 0.0l) 61 FAILURE 62 63 /* Verify that the conversions from DFP types to complex is 64 determined by the rules of conversion to the real part. */ 65 66 /* Convert _Decimal64 to _Complex float. */ 67 d64 = 0.125dl; 68 cf = d64; 69 if (__real__ cf != 0.125f) 70 FAILURE 71 /* Convert _Decimal128 to _Complex double. */ 72 d128 = 1.25E-7dl; 73 cd = d128; 74 if (__real__ cd != 1.25E-7) 75 FAILURE 76 77 /* Verify that conversion from complex to decimal floating types 78 results in the value of the real part converted to the result 79 type according to the rules of conversion between those types. */ 80 81 /* Convert _Complex float to decimal float types. */ 82 cf = 2.0f * __extension__ 1i + 2.25f; 83 d32 = cf; 84 d64 = cf; 85 d128 = cf; 86 if (d32 != 2.25DF) 87 FAILURE 88 if (d64 != 2.25DD) 89 FAILURE 90 if (d128 != 2.25DL) 91 FAILURE 92 93 /* Convert _Complex double to decimal float types. */ 94 cd = 2.0 * __extension__ 1i + 1.25; 95 d32 = cd; 96 d64 = cd; 97 d128 = cd; 98 if (d32 != 1.25DF) 99 FAILURE 100 if (d64 != 1.25DD) 101 FAILURE 102 if (d128 != 1.25DL) 103 FAILURE 104 105 /* Convert _Complex long double to decimal float types. */ 106 cld = 2.0l * __extension__ 1i + 0.0625l; 107 d32 = cld; 108 d64 = cld; 109 d128 = cld; 110 if (d32 != 0.0625DF) 111 FAILURE 112 if (d64 != 0.0625DD) 113 FAILURE 114 if (d128 != 0.0625DL) 115 FAILURE 116 117 FINISH 118 } 119