| 
 | 1 | +To: J3                                                     J3/25-189  | 
 | 2 | +From: Patrick Fasano  | 
 | 3 | +Subject: Requirements and specifications for interoperability with C  | 
 | 4 | +         interchange and extended types  | 
 | 5 | +Date: 2025-October-15  | 
 | 6 | + | 
 | 7 | +References:  | 
 | 8 | +      ISO/IEC 9899:2024 Programming languages -- C ("C23")  | 
 | 9 | +            (working draft N3220)  | 
 | 10 | +      WG5/N2249 Fortran 202Y Work Items  | 
 | 11 | +      23-176 Add extended floating-point types defined in ISO C23  | 
 | 12 | +            to ISO_C_BINDING  | 
 | 13 | +      ISO/IEC 60559:2020 Floating-Point arithmetic  | 
 | 14 | +      IEEE 754-2019 IEEE Standard for Floating-Point Arithmetic  | 
 | 15 | + | 
 | 16 | + | 
 | 17 | +1 Background  | 
 | 18 | +============  | 
 | 19 | + | 
 | 20 | +bg01. The ISO C23 specification (ISO/IEC 9899:2024) added support for  | 
 | 21 | +      interchange and extended floating-point types (C23 Annex H). The  | 
 | 22 | +      current Fortran 202Y work list WG5/N2249 includes adding  | 
 | 23 | +      interoperability with these types as accepted work item US05. At  | 
 | 24 | +      meeting #230 in June 2023, J3 accepted paper 23-176 as  | 
 | 25 | +      background/use-case for additional interchange types.  | 
 | 26 | + | 
 | 27 | +bg03. This paper contains formal requirements and specifications for  | 
 | 28 | +      Fortran 202Y proposal US05, "Add extended floating-point types  | 
 | 29 | +      defined in ISO C23 to ISO_C_BINDING".  | 
 | 30 | + | 
 | 31 | +2 Requirements  | 
 | 32 | +==============  | 
 | 33 | + | 
 | 34 | +rq01. The C23 standard adds a large number of new types, importing  | 
 | 35 | +      significant portions of ISO/IEC 60559 (a.k.a IEEE 754) into its  | 
 | 36 | +      specification. The most important of these for Fortran  | 
 | 37 | +      interoperability with C are the '_Float16', '_Float32',  | 
 | 38 | +      '_Float64', and '_Float128' types (and their related complex  | 
 | 39 | +      types). Requirements rq02-r05 deal with these new types. Many of  | 
 | 40 | +      the other types, covered by rq07-rq17, are marked as optional and  | 
 | 41 | +      could be dropped independently while keeping the rest of this  | 
 | 42 | +      paper. These optional requirements primarily serve to maintain  | 
 | 43 | +      parity with Annex H of C23.  | 
 | 44 | + | 
 | 45 | +rq02. The ISO_C_BINDING module should provide integer named constants  | 
 | 46 | +      for KIND parameters corresponding to the C interchange floating  | 
 | 47 | +      types '_Float16', '_Float32', '_Float64', and '_Float128'.  | 
 | 48 | + | 
 | 49 | +rq03. If the companion processor defines '__STDC_IEC_60559_BFP__' and  | 
 | 50 | +      '__STDC_IEC_60559_TYPES__', then the KIND parameters corresponding  | 
 | 51 | +      to '_Float32' and '_Float64' should equal those corresponding to  | 
 | 52 | +      'float' and 'double', respectively.  | 
 | 53 | + | 
 | 54 | +rq05. The ISO_C_BINDING module should provide integer named constants  | 
 | 55 | +      for KIND parameters corresponding to the C interchange complex  | 
 | 56 | +      types '_Float16_Complex', '_Float32_Complex', '_Float64_Complex',  | 
 | 57 | +      and '_Float128_Complex'. The values of the named constants should  | 
 | 58 | +      equal those of the respective constants for the interchange  | 
 | 59 | +      floating types.  | 
 | 60 | + | 
 | 61 | +rq07. The ISO_C_BINDING module should provide integer named constants  | 
 | 62 | +      for KIND parameters corresponding to the C extended floating types  | 
 | 63 | +      '_Float32x', '_Float64x', and '_Float128x'.  | 
 | 64 | + | 
 | 65 | +rq09. The ISO_C_BINDING module should provide integer named constants  | 
 | 66 | +      for KIND parameters corresponding to the C extended complex types  | 
 | 67 | +      '_Float32x_Complex', '_Float64x_Complex', and  | 
 | 68 | +      '_Float128x_Complex'. The values of the named constants should  | 
 | 69 | +      match those of the respective constants for the extended floating  | 
 | 70 | +      types.  | 
 | 71 | + | 
 | 72 | +rq11. The ISO_C_BINDING module should provide integer named constants  | 
 | 73 | +      for KIND parameters corresponding to the C interchange decimal  | 
 | 74 | +      floating types '_Decimal32', '_Decimal64', and '_Decimal128'.  | 
 | 75 | + | 
 | 76 | +3 Specifications  | 
 | 77 | +================  | 
 | 78 | + | 
 | 79 | +sp01. For all integer named constants to be added to the ISO_C_BINDING  | 
 | 80 | +      module, the value shall be a valid real kind type parameter or  | 
 | 81 | +      shall be -1 if the companion processor’s type does not have a  | 
 | 82 | +      precision equal to the precision of any of the Fortran processor’s  | 
 | 83 | +      real kinds, −2 if the companion processor’s type does not have a  | 
 | 84 | +      range equal to the range of any of the Fortran processor’s real  | 
 | 85 | +      kinds, −3 if the companion processor's type has neither the  | 
 | 86 | +      precision nor range of any of the Fortran processor’s real kinds,  | 
 | 87 | +      −4 if there is no interoperating Fortran processor kind for other  | 
 | 88 | +      reasons, and -5 if the companion processor does not define the  | 
 | 89 | +      corresponding C type.  | 
 | 90 | + | 
 | 91 | +sp02. To the ISO_C_BINDING module, add the following integer named  | 
 | 92 | +      constants for real KIND parameters:  | 
 | 93 | + | 
 | 94 | +      +----------------+--------------------+  | 
 | 95 | +      | Named constant | C interchange type |  | 
 | 96 | +      +----------------+--------------------+  | 
 | 97 | +      | C_FLOAT16      | _Float16           |  | 
 | 98 | +      | C_FLOAT32      | _Float32           |  | 
 | 99 | +      | C_FLOAT64      | _Float64           |  | 
 | 100 | +      | C_FLOAT128     | _Float128          |  | 
 | 101 | +      +----------------+--------------------+  | 
 | 102 | + | 
 | 103 | +      If the companion processor defines '__STDC_IEC_60559_BFP__' and  | 
 | 104 | +      '__STDC_IEC_60559_TYPES__', then the constants 'C_FLOAT32' and  | 
 | 105 | +      'C_FLOAT64' should have the same values as 'C_FLOAT' and  | 
 | 106 | +      'C_DOUBLE', respectively (C2023 H.2.4.2).  | 
 | 107 | + | 
 | 108 | +sp05. To the ISO_C_BINDING module, add the following integer named  | 
 | 109 | +      constants for real KIND parameters:  | 
 | 110 | + | 
 | 111 | +      +--------------------+--------------------+  | 
 | 112 | +      | Named constant     | C interchange type |  | 
 | 113 | +      +--------------------+--------------------+  | 
 | 114 | +      | C_FLOAT16_COMPLEX  | _Float16_Complex   |  | 
 | 115 | +      | C_FLOAT32_COMPLEX  | _Float32_Complex   |  | 
 | 116 | +      | C_FLOAT64_COMPLEX  | _Float64_Complex   |  | 
 | 117 | +      | C_FLOAT128_COMPLEX | _Float128_Complex  |  | 
 | 118 | +      +--------------------+--------------------+  | 
 | 119 | + | 
 | 120 | +      The values of each of these named constants shall be the same as  | 
 | 121 | +      the respective constants defined in sp01.  | 
 | 122 | + | 
 | 123 | +sp07. To the ISO_C_BINDING module, add the following integer named  | 
 | 124 | +      constants for real KIND parameters:  | 
 | 125 | + | 
 | 126 | +      +----------------+-----------------+  | 
 | 127 | +      | Named constant | C extended type |  | 
 | 128 | +      +----------------+-----------------+  | 
 | 129 | +      | C_FLOAT32X     | _Float32x       |  | 
 | 130 | +      | C_FLOAT64X     | _Float64x       |  | 
 | 131 | +      | C_FLOAT128X    | _Float128x      |  | 
 | 132 | +      +----------------+-----------------+  | 
 | 133 | + | 
 | 134 | +sp09. To the ISO_C_BINDING module, add the following integer named  | 
 | 135 | +      constants for real KIND parameters:  | 
 | 136 | + | 
 | 137 | +      +---------------------+--------------------+  | 
 | 138 | +      | Named constant      | C extended type    |  | 
 | 139 | +      +---------------------+--------------------+  | 
 | 140 | +      | C_FLOAT32X_COMPLEX  | _Float32x_Complex  |  | 
 | 141 | +      | C_FLOAT64X_COMPLEX  | _Float64x_Complex  |  | 
 | 142 | +      | C_FLOAT128X_COMPLEX | _Float128x_Complex |  | 
 | 143 | +      +---------------------+--------------------+  | 
 | 144 | + | 
 | 145 | +sp11. To the ISO_C_BINDING module, add the following integer named  | 
 | 146 | +      constants for real KIND parameters:  | 
 | 147 | + | 
 | 148 | +      +----------------+--------------------+  | 
 | 149 | +      | Named constant | C interchange type |  | 
 | 150 | +      +----------------+--------------------+  | 
 | 151 | +      | C_DECIMAL32    | _Decimal32         |  | 
 | 152 | +      | C_DECIMAL64    | _Decimal64         |  | 
 | 153 | +      | C_DECIMAL128   | _Decimal128        |  | 
 | 154 | +      +----------------+--------------------+  | 
 | 155 | + | 
 | 156 | +<<<<<<<< HEAD:proposals/fp_interop/25-189r1.txt  | 
 | 157 | +========  | 
 | 158 | +sp13. [if rq13] To the ISO_C_BINDING module, add the following integer  | 
 | 159 | +      named constants for real KIND parameters:  | 
 | 160 | + | 
 | 161 | +      +----------------+--------------------+  | 
 | 162 | +      | Named constant | C interchange type |  | 
 | 163 | +      +----------------+--------------------+  | 
 | 164 | +      | C_DECIMAL64X   | _Decimal64x        |  | 
 | 165 | +      | C_DECIMAL128X  | _Decimal128x       |  | 
 | 166 | +      +----------------+--------------------+  | 
 | 167 | + | 
 | 168 | +sp15. [if rq15] If the companion processor defines additional types of  | 
 | 169 | +      the form '_FloatN', the processor may add integer named constants  | 
 | 170 | +      of the form 'C_FLOATN'. If the companion processor defines  | 
 | 171 | +      additional types of the form '_FloatNx', the processor may add  | 
 | 172 | +      integer named constants of the form 'C_FLOATNX'. If the companion  | 
 | 173 | +      processor defines additional types of the form '_FloatN_Complex',  | 
 | 174 | +      the processor may add integer named constants of the form  | 
 | 175 | +      'C_FLOATN_COMPLEX'.  | 
 | 176 | + | 
 | 177 | +sp17. [if rq17] If the companion processor defines additional types of  | 
 | 178 | +      the form '_DecimalN', the processor may add integer named  | 
 | 179 | +      constants of the form 'C_DECIMALN'. If the companion processor  | 
 | 180 | +      defines additional types of the form '_DecimalNx', the processor  | 
 | 181 | +      may add integer named constants of the form 'C_DECIMALNX'.  | 
 | 182 | + | 
 | 183 | +>>>>>>>> d4187a6ce293e28b6c0f4e544a9be7ac2da219ee:proposals/fp_interop/25-189.txt  | 
 | 184 | +=== END ===  | 
0 commit comments