Real floating-point types

Generic, or binary, floating-point types consist of the following:
  • float
  • double
  • long double

IBM Extension Beginning of IBM® Extension.

Decimal floating-point types consist of the following:
  • _Decimal32
  • _Decimal64
  • _Decimal128

IBM Extension End of IBM Extension.

The magnitude ranges of the real floating-point types are given in the following table.
Table 1. Magnitude ranges of real floating-point types
Type Range
float approximately 1.2-38 to 3.438
double, long double approximately 2.2-308 to 1.8308
_Decimal32 0.000001-95 to 9.99999996
_Decimal64 0.000000000000001-383 to 9.999999999999999384
_Decimal128 0.000000000000000000000000000000001-6143 to 9.9999999999999999999999999999999996144
If a floating-point constant is too large or too small, the result is undefined by the language.

The declarator for a simple floating-point declaration is an identifier. Initialize a simple floating-point variable with a float constant or with a variable or expression that evaluates to an integer or floating-point number.

IBM Extension Beginning of IBM Extension.

You can use decimal floating-point types with any of the operators that are supported for binary floating-point types. You can also perform implicit or explicit conversions between decimal floating-point types and all other integral types or generic floating-point types. However, these are the restrictions on the use of decimal floating-point types with other arithmetic types:
  • You cannot mix decimal floating-point types with generic floating-point types in arithmetic expressions, unless you use explicit conversions.
  • Implicit conversion between decimal floating-point types and real binary floating-point types is only allowed via assignment, with the simple assignment operator =. Implicit conversion is performed in simple assignments, which also include function argument assignments and function return values.

IBM Extension End of IBM Extension.