Next: , Previous: Complex, Up: C Extensions


6.11 Additional Floating Types

ISO/IEC TS 18661-3:2015 defines C support for additional floating types _Floatn and _Floatnx, and GCC supports these type names; the set of types supported depends on the target architecture. These types are not supported when compiling C++. Constants with these types use suffixes fn or Fn and fnx or Fnx. These type names can be used together with _Complex to declare complex types.

As an extension, GNU C and GNU C++ support additional floating types, __float80 and __float128 to support 80-bit (XFmode) and 128-bit (TFmode) floating types; these are aliases for the type names _Float64x and _Float128. Support for additional types includes the arithmetic operators: add, subtract, multiply, divide; unary arithmetic operators; relational operators; equality operators; and conversions to and from integer and other floating types. Use a suffix ‘w’ or ‘W’ in a literal constant of type __float80 or type __ibm128. Use a suffix ‘q’ or ‘Q’ for _float128.

On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex types using the corresponding internal complex type, XCmode for __float80 type and TCmode for __float128 type:

     typedef _Complex float __attribute__((mode(TC))) _Complex128;
     typedef _Complex float __attribute__((mode(XC))) _Complex80;

In order to use _Float128, __float128 and __ibm128 on PowerPC Linux systems, you must use the -mfloat128. It is expected in future versions of GCC that _Float128 and __float128 will be enabled automatically. In addition, there are currently problems in using the complex __float128 type. When these problems are fixed, you would use the following syntax to declare _Complex128 to be a complex __float128 type:

On the PowerPC Linux VSX targets, you can declare complex types using the corresponding internal complex type, KCmode for __float128 type and ICmode for __ibm128 type:

     typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
     typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;

Not all targets support additional floating-point types. __float80 and __float128 types are supported on x86 and IA-64 targets. The __float128 type is supported on hppa HP-UX. The __float128 type is supported on PowerPC 64-bit Linux systems by default if the vector scalar instruction set (VSX) is enabled. The _Float128 type is supported on all systems where __float128 is supported or where long double has the IEEE binary128 format. The _Float64x type is supported on all systems where __float128 is supported. The _Float32 type is supported on all systems supporting IEEE binary32; the _Float64 and Float32x types are supported on all systems supporting IEEE binary64. GCC does not currently support _Float16 or _Float128x on any systems.

On the PowerPC, __ibm128 provides access to the IBM extended double format, and it is intended to be used by the library functions that handle conversions if/when long double is changed to be IEEE 128-bit floating point.