Cray C Extension Use
Cray C extends the complex data facilities defined by standard C with these extensions.
Complex Data Extensions
- Imaginary constants
- Incrementing or decrementing _Complex data
RiR is either a floating constant or an integer constant; no space or other character can appear between R and i. If compiling in strict conformance mode (-h conform), the Cray imaginary constants are not available.
#include <complex.h>
double complex z1 = 1.2 + 3.4i;
double complex z2 = 5i;The other extension to the complex data facility allows the prefix– and postfixincrement and decrement operators to be applied to the _Complex data type. The operations affect only the real portion of a complex number.
fortran Keyword
In extended mode, the identifier fortran is treated as a keyword. It specifies a storage class that can be used to declare a Fortran-coded external function. The use of the fortran keyword when declaring a function causes the compiler to verify that the arguments used in each call to the function are pass by addresses; any arguments that are not addresses are converted to addresses.
As in any function declaration, an optional type-specifier declares the type returned, if any. Type int is the default; type void can be used if no value is returned (by a Fortran subroutine). The fortran storage class causes conversion of lowercase function names to uppercase, and, if the function name ends with an underscore character, the trailing underscore character is stripped from the function name. (Stripping the trailing underscore character is in keeping with UNIX practice.)
Functions specified with a fortran storage class must not be declared elsewhere in the file with a static storage class.
The fortran keyword is not allowed in Cray C++.
An example using the fortran keyword is shown in Interlanguage Communication.
Hexadecimal Floating-point Constants
The Cray C compiler supports the standard hexadecimal floating constant notations and the Cray hexadecimal floating constant notation. The standard hexadecimal floating constants are portable and have sizes that are dependent upon the hardware. The remainder of this section discusses the Cray hexadecimal floating constant.
The Cray hexadecimal floating constant feature is not portable, because identical hexadecimal floating constants can have different meanings on different systems. It can be used whenever traditional floating-point constants are allowed.
The hexadecimal constant has the usual syntax: 0x (or 0X) followed by hexadecimal characters. The optional floating suffix has the same form as for normal floating constants: f or F (for float), l or L (for long), optionally followed by an i (imaginary).
The constant must represent the same number of bits as its type, which is determined by the suffix (or the default of double). The constant's bit length is four times the number of hexadecimal digits, including leading zeros.
0x7f7fffff.f32-bit float
0x0123456789012345.
64-bit double
The value of a hexadecimal floating constant is interpreted as a value in the specified floating type. This uses an unsigned integral type of the same size as the floating type, regardless of whether an object can be explicitly declared with such a type. No conversion or range checking is performed. The resulting floating value is defined in the same way as the result of accessing a member of floating type in a union after a value has been stored in a different member of integral type.
int main(void)
{
float f1, f2;
double g1, g2;
f1 = 0x3ec00000.f;
f2 = 0x3fc00000.f;
g1 = 0x40fa400100000000.;
g2 = 0x40fa400200000000.;
printf("f1 = %8.8g\n", f1);
printf("f2 = %8.8g\n", f2);
printf("g1 = %16.16g\n", g1);
printf("g2 = %16.16g\n", g2);
return 1;
}f1 = 0.375
f2 = 1.5
g1 = 107520.0625
g2 = 107520.125