To: J3 J3/22-185r1 From: Jeff Hammond Subject: C interoperability for new interchange floating-point types Date: 2022-October-24 1. Introduction =============== The ISO C23 specification is expected to ratify support for extended floating point types, specifically, 16-bit, 32-bit, 64-bit, and 128-bit real numbers [1,2]. These types should be added to C-Fortran interoperability features so that Fortran's REAL16 and REAL128 types (and their complex counterparts) can be used in a C-interoperable context. For completeness, we also add support for the C23 types _Float32, _Float64 and their complex counterparts, although these are expected to be synonymous with C float and double in most cases. This change is proposed for Fortran 2026. 2 . Proposal ============ In 18.2.2 Named constants and derived types in the module, change "The values of C_FLOAT, C_DOUBLE, and C_LONG_DOUBLE shall each ... The values of C_FLOAT_COMPLEX, C_DOUBLE_COMPLEX, and C_LONG_DOUBLE_COMPLEX shall be the same as those of C_FLOAT, C_DOUBLE, and C_LONG_DOUBLE, respectively." to "The values of C_FLOAT16, C_FLOAT, C_FLOAT32, C_DOUBLE, C_FLOAT64, C_LONG_DOUBLE and C_FLOAT128 shall each ... The values of C_FLOAT16_COMPLEX, C_FLOAT_COMPLEX, C_FLOAT32_COMPLEX, C_DOUBLE_COMPLEX, C_FLOAT64_COMPLEX, C_LONG_DOUBLE_COMPLEX and C_FLOAT128_COMPLEX shall be the same as those of C_FLOAT16, C_FLOAT, C_DOUBLE, C_LONG_DOUBLE, and C_FLOAT128 respectively." In Table 18.2: Interoperability between Fortran and C types, change Fortran type | Named constant from the ISO_C_BINDING module .. | C type ... | C_FLOAT | float REAL | C_DOUBLE | double | C_LONG_DOUBLE | long double -------------|---------------------------|----------------------- | C_FLOAT_COMPLEX | float _Complex COMPLEX | C_DOUBLE_COMPLEX | double _Complex | C_LONG_DOUBLE_COMPLEX | long double _Complex ... to Fortran type | Named constant from the ISO_C_BINDING module .. | C type ... | C_FLOAT16 | _Float16 | C_FLOAT | float | C_FLOAT32 | _Float32 REAL | C_DOUBLE | double | C_FLOAT64 | _Float64 | C_LONG_DOUBLE | long double | C_FLOAT128 | _Float128 -------------|---------------------------|----------------------- | C_FLOAT16_COMPLEX | _Float16 _Complex | C_FLOAT_COMPLEX | float _Complex | C_FLOAT32_COMPLEX | _Float32 _Complex COMPLEX | C_DOUBLE_COMPLEX | double _Complex | C_FLOAT64_COMPLEX | _Float64 _Complex | C_LONG_DOUBLE_COMPLEX | long double _Complex | C_FLOAT128_COMPLEX | _Float128 _Complex ... 3 . Discussion ============== The omission of a second underscore in the Fortran names is intentional. The leading underscore in C names exists due to how C reserves names and is not a descriptive part of the name. 4 . References ============== 1. ISO/IEC TS 18661-3:2015 https://www.iso.org/standard/65615.html 2. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2601.pdf ===END===