Intel® Fortran Compiler 18.0 Developer Guide and Reference
Elemental Intrinsic Function (Generic): Converts a value to real type.
result = REAL (a[,kind])
a |
(Input) Must be of type integer, real, or complex, or a binary, octal, or hexadecimal literal constant. |
kind |
(Input; optional) Must be a scalar integer constant expression. |
The result type is real. If kind is present, the kind parameter is that specified by kind; otherwise, the kind parameter of the result is shown in the following table. If the processor cannot represent the result value in the kind of the result, the result is undefined.
Functions that cause conversion of one data type to another type have the same effect as the implied conversion in assignment statements.
The result value depends on the type and absolute value of a as follows:
If a is integer or real, the result is equal to an approximation of a. If a is complex, the result is equal to an approximation of the real part of a.
If a is a binary, octal, or hexadecimal literal constant, the value of the result is the value whose bit sequence according to the model in Bit Model is the same as that of a as modified by padding or truncation according to the following:
If the length of the sequence of bits specified by a is less than the size in bits of a scalar variable of the same type and kind type parameter as the result, the binary, octal, or hexadecimal literal constant is treated as if it were extended to a length equal to the size in bits of the result by padding on the left with zero bits.
If the length of the sequence of bits specified by a is greater than the size in bits of a scalar variable of the same type and kind type parameter as the result, the binary, octal, or hexadecimal literal constant is treated as if it were truncated from the left to a length equal to the size in bits of the result.
If a binary, octal, or hexadecimal literal constant is truncated as an argument to intrinsic function REAL, the discarded bits must all be zero.
Specific Name 1 |
Argument Type |
Result Type |
---|---|---|
INTEGER(1) |
REAL(4) |
|
FLOATI |
INTEGER(2) |
REAL(4) |
FLOAT 2, 3 |
INTEGER(4) |
REAL(4) |
REAL 2 |
INTEGER(4) |
REAL(4) |
FLOATK |
INTEGER(8) |
REAL(4) |
REAL(4) |
REAL(4) |
|
SNGL 2, 4 |
REAL(8) |
REAL(4) |
SNGLQ |
REAL(16) |
REAL(4) |
COMPLEX(4) |
REAL(4) |
|
COMPLEX(8) |
REAL(8) |
|
1 These specific functions cannot be passed as actual arguments. 2The setting of compiler options specifying real size can affect FLOAT, REAL, and SNGL. 3 Or FLOATJ. For compatibility with older versions of Fortran, FLOAT is generic, allowing any kind of INTEGER argument, and returning a default real result. 4 For compatibility with older versions of Fortran, SNGL is generic, allowing any kind of REAL argument, and returning a default real result. |
If the argument is a a binary, octal, or hexadecimal constant, the result is affected by the assume old-boz option. The default option setting, noold-boz, treats the argument as a bit string that represents a value of the data type of the intrinsic, that is, the bits are not converted. If setting old-boz is specified, the argument is treated as a signed integer and the bits are converted.
REAL (-4) has the value -4.0.
REAL (Y) has the same kind parameter and value as the real part of complex variable Y.
If C is complex, C%RE is the same as REAL (C).