Previous | Contents | Index |
Intrinsic COMPLEX (KIND=8) or COMPLEX*16 (same as DOUBLE COMPLEX) data is 16 contiguous bytes containing a pair of REAL*8 values stored in IEEE T_float format.
The low-order eight bytes contain REAL (KIND=8) data that represents the real part of the complex data. The high-order eight bytes contain REAL (KIND=8) data that represents the imaginary part of the complex data, as shown in Figure 9-10.
Figure 9-10 COMPLEX (KIND =8) or COMPLEX*16 Representation
The limits and underflow characteristics for REAL (KIND=8) apply to the two separate real and imaginary parts of a COMPLEX (KIND=8) or COMPLEX*16 number. Like REAL (KIND=8) or REAL*8 numbers, the sign bit representation is 0 (zero) for positive numbers and 1 for negative numbers.
For More Information:
Exceptional values usually result from a computation and include plus infinity, minus infinity, NaN, and denormalized numbers.
Floating-point numbers can be one of the following:
A NaN or infinity value might result from a calculation that contains a divide by zero, overflow, or invalid data.
A denormalized number occurs when the result of a calculation falls within the denormalized range for that data type (subnormal value).
To control floating-point exception handling at run time for the main program, use the appropriate -fpen option. The callable for_set_fpe routine allows further control for subprogram use or conditional use during program execution.
If an exceptional value is used in a calculation, an unrecoverable exception can occur unless you specify the appropriate -fpen option or use the for_set_fpe routine. Denormalized numbers can be processed as is, set equal to zero with program continuation or a program stop, and generate warning messages (see Section 3.35).
Table 9-2 lists the hexadecimal (hex) values of the IEEE exceptional floating-point numbers in Alpha systems, for S_float (single precision), T_float (double precision), and X_float (extended precision) formats:
Exceptional Number | Hex Value |
---|---|
S_float Representation | |
Infinity (+) | Z ' 7F800000 ' |
Infinity (--) | Z ' FF800000 ' |
Zero (+0) | Z ' 00000000 ' |
Zero (--0) | Z ' 80000000 ' |
Quiet NaN (+) | From Z ' 7FC00000 ' to Z ' 7FFFFFFF ' |
Quiet NaN (--) | From Z ' FFC00000 ' to Z ' FFFFFFFF ' |
Signaling NaN (+) | From Z ' 7F800001 ' to Z ' 7FBFFFFF ' |
Signaling NaN (--) | From Z ' FF800001 ' to Z ' FFBFFFFF ' |
T_float Representation | |
Infinity (+) | Z ' 7FF0000000000000 ' |
Infinity (--) | Z ' FFF0000000000000 ' |
Zero (+0) | Z ' 0000000000000000 ' |
Zero (-0) | Z ' 8000000000000000 ' |
Quiet NaN (+) | From Z ' 7FF8000000000000 ' to Z ' 7FFFFFFFFFFFFFFF ' |
Quiet NaN (--) | From Z ' FFF8000000000000 ' to Z ' FFFFFFFFFFFFFFFF ' |
Signaling NaN (+) | From Z ' 7FF0000000000001 ' to Z ' 7FF7FFFFFFFFFFFF ' |
Signaling NaN (--) | From Z ' FFF0000000000001 ' to Z ' FFF7FFFFFFFFFFFF ' |
X_float Representation | |
Infinity (+) | Z ' 7FFF0000000000000000000000000000 ' |
Infinity (--) | Z ' FFFF0000000000000000000000000000 ' |
Zero (+0) | Z ' 000000000000000000000000000000000 ' |
Zero (--0) | Z ' 800000000000000000000000000000000 ' |
Quiet NaN (+) | From Z ' 7FFF80000000000000000000000000000 ' to Z ' 7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ' |
Quiet NaN (--) | From Z ' FFFF80000000000000000000000000000 ' to Z ' FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ' |
Signaling NaN (+) | From Z ' 7FFF00000000000000000000000000001 ' to Z ' 7FFF7FFFFFFFFFFFFFFFFFFFFFFFFFFFF ' |
Signaling NaN (--) | From Z ' FFFF00000000000000000000000000001 ' to Z ' FFFF7FFFFFFFFFFFFFFFFFFFFFFFFFFFF ' |
DIGITAL Fortran 90 supports IEEE exception handling, allowing you to test for infinity by using a comparison of floating-point data (such as generating positive infinity by using a calculation like x=1.0/0 and comparing x to the calculated number).
The appropriate f90 command -fpen options or calling the for_set_fpe routine with appropriate arguments allows program continuation when a calculation results in a divide by zero, overflow, or invalid data arithmetic exception, generating an exceptional value (a NaN or Infinity (+ or --)).
To test for a NaN when DIGITAL Fortran 90 allows continuation for arithmetic exceptions, you can use the ISNAN intrinsic function.
For example, you might use the following code to test a DOUBLE PRECISION (REAL (KIND=8)) value:
DOUBLE PRECISION A, B, F A = 0. B = 0. ! Perform calculations with variables A and B . . . ! f contains the value to check against a particular NaN F = A / B IF (ISNAN(F)) THEN WRITE (6,*) '--> Variable F contains a NaN value <--' ENDIF ! Inform user that f has the hardware quiet NaN value ! Perform calculations with variable F (or stop program early) END PROGRAM |
This program might be compiled with -fpe2 or -fpe4 to allow:
% f90 -fpe2 isnan.for % a.out forrtl: error: floating invalid --> Variable F contains a NaN value <-- forrtl: info: 1 floating invalid traps |
The FP_CLASS intrinsic function is also available to check for exceptional values (see the DIGITAL Fortran Language Reference Manual and the file /usr/include/fordef.f ).
For More Information:
A character string is a contiguous sequence of bytes in memory, as shown in Figure 9-11.
Figure 9-11 CHARACTER Data Representation
A character string is specified by two attributes: the address A of the first byte of the string, and the length L of the string in bytes. The length L of a string is in the range 1 through 65,535.
For More Information:
Hollerith constants are stored internally, one character per byte. When Hollerith constants contain the ASCII representation of characters, they resemble the storage of character data (see Figure 9-11).
When Hollerith constants store numeric data, they usually have a length of one, two, four, or eight bytes and resemble the corresponding numeric data type.
For More Information:
This chapter describes how you can use DIGITAL Fortran 90 to read and write unformatted numeric data in certain nonnative formats, including big endian IEEE and VAX floating-point formats.
On DIGITAL UNIX systems, DIGITAL Fortran 90 supports the following little endian floating-point formats in memory:
Floating-Point Size | Format in Memory |
---|---|
KIND=4 | IEEE S_float |
KIND=8 | IEEE T_float |
KIND=16 | DIGITAL IEEE style X_float |
If your program needs to read or write unformatted data files containing a floating-point format that differs from the format in memory for that data size, you can request that the unformatted data be converted.
Converting unformatted data is generally faster than converting
formatted data and is less likely to lose precision for floating-point
numbers.
10.1 Endian Order of Numeric Formats
Data storage in different computers use a convention of either little endian or big endian storage. The storage convention generally applies to numeric values that span multiple bytes, as follows:
Figure 10-1 shows the difference between the two byte-ordering schemes.
Figure 10-1 Little and Big Endian Storage of an INTEGER Value
Moving data files between big endian and little endian computers
requires that the data be converted.
10.2 Native and Supported Nonnative Numeric Formats
DIGITAL Fortran 90 provides the capability for programs to read and write unformatted data (originally written using unformatted I/O statements) in several nonnative floating-point formats and in big endian INTEGER or floating-point format.
When reading a nonnative unformatted format, the nonnative format on disk must be converted to native format in memory. Similarly, native data in memory can be written to a nonnative unformatted format. If a converted nonnative value is outside the range of the native data type, a run-time message appears (listed in Table 8-2).
Supported native and nonnative floating-point formats include:
The native memory format uses little endian integers and little endian IEEE floating-point formats, as follows:
Table 10-1 lists the keywords for the supported unformatted file data formats. Use the appropriate keyword after the -convert option (such as -convert cray ) or as an environment variable value (see Section 10.4).
Recognized Keyword1 | Description |
---|---|
BIG_ENDIAN | Big endian integer data of the appropriate INTEGER size (one, two, or four bytes) and big endian IEEE floating-point formats for REAL and COMPLEX single- and double-precision numbers. INTEGER (KIND=1) or INTEGER*1 data is the same for little endian and big endian. |
CRAY | Big endian integer data of the appropriate INTEGER size (one, two, four, or eight bytes) and big endian CRAY proprietary floating-point format for REAL and COMPLEX single- and double-precision numbers. |
FDX | Native little endian integers of the appropriate INTEGER size (one, two, four, or eight bytes) and the following little endian DIGITAL proprietary floating-point formats: |
FGX | Native little endian integers of the appropriate INTEGER size (one, two, four, or eight bytes) and the following little endian DIGITAL proprietary floating-point formats: |
IBM | Big endian integer data of the appropriate INTEGER size (one, two, or four bytes) and big endian IBM proprietary (System\370 and similar) floating-point format for REAL and COMPLEX single- and double-precision numbers. |
LITTLE_ENDIAN | Native little endian integers of the appropriate INTEGER size (one, two, four, or eight bytes) and the following native little endian IEEE floating-point formats: |
NATIVE | No conversion occurs between memory and disk. This is the default for unformatted files. |
VAXD | Native little endian integers of the appropriate INTEGER size (one, two, four, or eight bytes) and the following little endian VAX DIGITAL proprietary floating-point formats: |
VAXG | Native little endian integers of the appropriate INTEGER size (one, two, four, or eight bytes) and the following little endian VAX DIGITAL proprietary floating-point formats: |
While this solution is not expected to fulfill all floating-point conversion needs, it provides the capability to read and write various types of unformatted nonnative floating-point data.
For More Information:
1 IEEE floating-point formats are defined in the IEEE Standard for Binary Floating-Point Arithmetic, ANSI/IEEE Standard 754-1985, Institute of Electrical and Electronics Engineers, August 1985. |
Previous | Next | Contents | Index |