Floating-point type specifiers fall into the following
categories:
- Real floating-point types
- Complex floating-point types
Real floating-point types
Generic,
or binary, floating-point types consist of the following:
Decimal
floating-point types consist of the following:
- _Decimal32
- _Decimal64
- _Decimal128
Note: In order for the _Decimal32, _Decimal64,
and _Decimal128 keywords to be recognized, you must
compile with the DFP compiler option. See DFP compiler option in the z/OS XL C/C++ User's Guide for
details.
The magnitude ranges of the real
floating-point types are given in the following table.
Table 1. Magnitude
ranges of real floating-point typesType |
Range |
FLOAT(HEX): |
float |
5.397605-79 - 7.23700575 |
double |
5.397605-79 - 7.23700675 |
long double |
5.397605-79 - 7.23700675 |
FLOAT(IEEE): |
float |
1.175494-38 - 3.40282338 |
double |
2.225074-308 - 1.797693308 |
long double |
3.362103-4932 - 1.1897314932 |
DFP: |
_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.
Note
that z/OS® XL C/C++ supports
IEEE binary floating-point variables as well as IBM® z/Architecture® hexadecimal
floating-point variables. For details on the FLOAT compiler option,
see the z/OS XL C/C++
User's Guide.
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.
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, generic floating-point types, or packed decimals.
However, there are restrictions on the use of decimal floating-point
types with other arithmetic types as follows:
- You cannot mix decimal floating-point types with generic floating-point
types or complex 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. See Floating-point conversions for
details.
Complex floating-point types
Complex floating-point types are introduced in the C99
standard.
The z/OS XL C/C++ compiler
supports this feature as an IBM extension. The complex floating-point
type specifiers are as follows:
- float _Complex
- double _Complex
- long double _Complex
The representation and alignment requirements of
a complex type are the same as an array type containing two elements
of the corresponding real type. The real part is equal to the first
element; the imaginary part is equal to the second element.
The
equality and inequality operators have the same behavior as for real
types. None of the relational operators may have a complex type as
an operand.
As an extension to C99, complex numbers may also be
operands to the unary operators ++ (increment), -- (decrement),
and ~ (bitwise negation).