# Compaq Fortran
User Manual for
Tru64 UNIX and
Linux Alpha Systems

Previous | Contents | Index

# Chapter 9
Data Types and Representation

This chapter contains the following topics:

- Section 9.1, Summary of Data Types and Characteristics
- Section 9.2, Integer Data Representations
- Section 9.3, Logical Data Representations
- Section 9.4, Native IEEE Floating-Point Representations and Exceptional Values
- Section 9.5, Character Representation
- Section 9.6, Hollerith Representation

Note In figures in this chapter, the symbol `:A` specifies the address of the byte containing bit 0, which is the starting address of the represented data element. Compaq Fortran expects numeric data to be in native little endian order, in which the least-significant, rightmost bit (bit 0) or byte has a lower address than the most-significant, leftmost bit (or byte).

For More Information:

- On using nonnative big endian and VAX floating-point formats, see Chapter 10.
- On using Compaq Fortran I/O, see Chapter 7.

# 9.1 Summary of Data Types and Characteristics

Table 9-1 lists the intrinsic data types provided by Compaq Fortran, the storage required, and valid numeric ranges.

Table 9-1 Compaq Fortran Intrinsic Data Types, Storage, and Numeric Ranges
Data Type | Bytes | Description
--- | --- | ---
BYTE (INTEGER*1) | 1 (8 bits) | A BYTE declaration is a signed integer data type equivalent to INTEGER*1 or INTEGER (KIND=1).
INTEGER | 1, 2, 4, or 8 | Signed integer whose size is controlled by a kind type parameter or, if a kind type parameter (or size specifier) is omitted, certain `f90` or `fort` command options (see Section 9.2.1).
INTEGER (KIND=1) INTEGER*1 | 1 (8 bits) | Signed integer value from --128 to 127 (--2**7 to 2**7--1). Unsigned values from 0 to 255 (2**8-1) 1.
INTEGER (KIND=2) INTEGER*2 | 2 (16 bits) | Signed integer value from --32,768 to 32,767 (--2**15 to 2**15--1). Unsigned values from 0 to 65535 (2**16-1) 1.
INTEGER (KIND=4) INTEGER*4 | 4 (32 bits) | Signed integer value from --2,147,483,648 to 2,147,483,647 (--2**31 to 2**31--1). Unsigned values from 0 to 4,294,967,295 (2**32-1) 1.
INTEGER (KIND=8) INTEGER*8 | 8 (64 bits) | Signed integer value from --9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (--2**63 to 2**63--1).
LOGICAL | 1, 2, 4, or 8 | Logical value whose size is controlled by a kind type parameter or, if a kind type parameter (or size specifier) is omitted, certain `f90` command options (see Section 9.3).
LOGICAL (KIND=1) LOGICAL*1 | 1 (8 bits) | Logical values .TRUE. or .FALSE. 2
LOGICAL (KIND=2) LOGICAL*2 | 2 (16 bits) | Logical values .TRUE. or .FALSE. 2
LOGICAL (KIND=4) LOGICAL*4 | 4 (32 bits) | Logical values .TRUE. or .FALSE. 2
LOGICAL (KIND=8) LOGICAL*8 | 8 (64 bits) | Logical values .TRUE. or .FALSE. 2
REAL | 4, 8, or 16 | Real floating-point numbers whose size is controlled by a kind type parameter or, if a kind type parameter (or size specifier) is omitted, certain `f90` command options (see Section 9.4.1).
REAL (KIND=4) REAL*4 | 4 (32 bits) | Single-precision real floating-point values in IEEE S_float format ranging from 1.17549435E--38 to 3.40282347E38. Values between 1.17549429E--38 and 1.40129846E--45 are denormalized 3. You cannot write a constant for a denormalized number.
DOUBLE PRECISION REAL (KIND=8) REAL*8 | 8 (64 bits) | Double-precision real floating-point values in IEEE T_float format ranging from 2.2250738585072013D-308 to 1.7976931348623158D308. Values between 2.2250738585072008D--308 and 4.94065645841246544D--324 are denormalized 3. You cannot write a constant for a denormalized number.
REAL (KIND=16) REAL*16 | 16 (128 bits) | Extended-precision real floating-point values in Compaq IEEE style X_float format ranging from 6.4751751194380251109244389582276465524996Q-4966 to 1.189731495357231765085759326628007016196477Q4932.
COMPLEX | 8, 16, or 32 | Complex floating-point numbers whose size is controlled by a kind type parameter or, if a kind type parameter (or size specifier) is omitted, the `f90` command options described in Section 9.4.1.
COMPLEX (KIND=4) COMPLEX*8 | 8 (64 bits) | Single-precision complex floating-point values in a pair of IEEE S_float format parts: real and imaginary. The real and imaginary parts range from 1.17549435E--38 to 3.40282347E38. Values between 1.17549429E--38 and 1.40129846E--45 are denormalized 3. You cannot write a constant for a denormalized number.
DOUBLE COMPLEX COMPLEX (KIND=8) COMPLEX*16 | 16 (128 bits) | Double-precision complex floating-point values in a pair of IEEE T_float format parts: real and imaginary. The real and imaginary parts each range from 2.2250738585072013D-308 to 1.7976931348623158D308. Values between 2.2250738585072008D--308 and 4.94065645841246544D--324 are denormalized 3. You cannot write a constant for a denormalized number.
COMPLEX (KIND=16) COMPLEX*32 | 32 (256 bits) | Extended-precision complex floating-point values in a pair of Compaq IEEE style X_float format parts: real and imaginary. The real and imaginary parts each range from 6.4751751194380251109244389582276465524996Q-4966 to 1.189731495357231765085759326628007016196477Q4932.
CHARACTER | 1 byte (8 bits) per character | Character data represented by character code convention. Character declarations can be in the form CHARACTER(LEN= n), CHARACTER( n), or CHARACTER* n, where n is the number of bytes or n can be (*) to indicate passed-length format.
HOLLERITH | 1 byte (8 bits) per Hollerith character | Hollerith constants.

1This range is allowed for assignment to variables of this type, but the data type is treated as signed in arithmetic operations.
2Logical data type ranges correspond to their comparable integer data type ranges. For example, in LOGICAL(KIND=2) L, the range for L is the same as the range for INTEGER(KIND=2) integers.
3For more information on floating-point underflow, see Section 3.44.

In addition to the intrinsic numeric data types, you can also define nondecimal (binary, octal, or hexadecimal) constants as explained in the Compaq Fortran Language Reference Manual.

# 9.2 Integer Data Representations

Integer data lengths can be one, two, four, or eight bytes in length.

Integer data is signed with the sign bit being 0 (zero) for positive numbers and 1 for negative numbers.

To improve performance, avoid using 2-byte or 1-byte integer declarations (see Chapter 5).

## 9.2.1 Integer Declarations and f90/fort Compiler Options

The default size used for an INTEGER data declaration without a kind parameter is INTEGER (KIND=4) (same as INTEGER*4), unless you do one of the following:

- Explicitly declare the length of an INTEGER by using a kind parameter, such as INTEGER (KIND=8). Compaq Fortran provides intrinsic INTEGER kinds of 1, 2, 4, and 8. Each INTEGER kind number corresponds to number of bytes used by that intrinsic representation.
  To obtain the kind of a variable, use the KIND intrinsic function. You can also use a size specifier, such as INTEGER*4, but be aware this is an extension to the Fortran 95/90 standards.
- Use the `f90` command `-i2` , `-integer_size nn` , or `-i8` options to control the size of all INTEGER declarations without a kind parameter (see Section 3.53).

## 9.2.2 INTEGER (KIND=1) or INTEGER*1 Representation

Intrinsic INTEGER (KIND=1) or INTEGER*1 signed values range from --128 to 127 and are stored in a two's complement representation. For example:

    +22 = 16(hex)
     -7 = F9(hex)

INTEGER (KIND=1) or INTEGER*1 values are stored in one byte, as shown in Figure 9-1.

Figure 9-1 INTEGER (KIND=1) or INTEGER*1 Representation

## 9.2.3 INTEGER (KIND=2) or INTEGER*2 Representation

Intrinsic INTEGER (KIND=2) or INTEGER*2 signed values range from --32,768 to 32,767 and are stored in a two's complement representation. For example:

    +22 = 0016(hex)
     -7 = FFF9(hex)

INTEGER (KIND=2) or INTEGER*2 values are stored in two contiguous bytes, as shown in Figure 9-2.

Figure 9-2 INTEGER (KIND=2) or INTEGER*2 Representation

## 9.2.4 INTEGER (KIND=4) or INTEGER*4 Representation

Intrinsic INTEGER (KIND=4) or INTEGER*4 signed values range from --2,147,483,648 to 2,147,483,647 and are stored in a two's complement representation. INTEGER (KIND=4) or INTEGER*4 values are stored in four contiguous bytes, as shown in Figure 9-3.

Figure 9-3 INTEGER (KIND=4) or INTEGER*4 Representation

## 9.2.5 INTEGER (KIND=8) or INTEGER*8 Representation

Intrinsic INTEGER (KIND=8) or INTEGER*8 signed values range from --9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 and are stored in a two's complement representation. INTEGER*8 or INTEGER (KIND=8) values are stored in eight contiguous bytes, as shown in Figure 9-4.

Figure 9-4 INTEGER (KIND=8) or INTEGER*8 Representation

For More Information:

- On defining constants and assigning values to variables, see the Compaq Fortran Language Reference Manual.
- On intrinsic functions related to the various data types, such as SELECTED_INT_KIND, see the Compaq Fortran Language Reference Manual.
- On the `f90` command options that control the size of default INTEGER declarations, see Section 3.53.

# 9.3 Logical Data Representations

Logical data can be one, two, four, or eight bytes in length.

The default size used for a LOGICAL data declaration without a kind parameter (or size specifier) is LOGICAL (KIND=4) (same as LOGICAL*4), unless you do one of the following:

- Explicitly declare the length of a LOGICAL declaration by using a kind parameter, such as LOGICAL (KIND=4). Compaq Fortran provides intrinsic LOGICAL kinds of 1, 2, 4, and 8. Each LOGICAL kind number corresponds to number of bytes used by that intrinsic representation.
  To obtain the kind of a variable, use the KIND intrinsic function. You can also use a size specifier, such as LOGICAL*4, but be aware this is an extension to the Fortran 95/90 standards.
- Use the `f90` command `-i2` , `-integer_size nn` , or `-i8` options to control the size of LOGICAL declarations without a kind parameter or size specifier (see Section 3.53).

To improve default performance, avoid using 2-byte or 1-byte logical declarations (see Chapter 5).

Intrinsic LOGICAL*1 or LOGICAL (KIND=1) values are stored in a single byte.

Logical (intrinsic) values can also be stored in the following sizes of contiguous bytes starting on an arbitrary byte boundary:

- Two bytes (LOGICAL (KIND=2) or LOGICAL*2)
- Four bytes (LOGICAL (KIND=4) or LOGICAL*4)
- Eight bytes (LOGICAL (KIND=8) or LOGICAL*8)

The low-order bit determines whether the logical value is true or false. Logical variables can also be interpreted as integer data (an extension to the Fortran 95/90 standards). For example, in addition to having logical values .TRUE. and .FALSE., LOGICAL*1 data can also have values in the range --128 to 127.

LOGICAL*1, LOGICAL*2, LOGICAL*4, and LOGICAL*8 data representations appear in Figure 9-5.

Figure 9-5 LOGICAL Representations

For More Information:

- On defining constants and assigning values to variables, see the Compaq Fortran Language Reference Manual.
- On intrinsic functions related to the various data types, see the Compaq Fortran Language Reference Manual.
- On the `f90` command options that control the size of default LOGICAL declarations, see Section 3.53.

# 9.4 Native IEEE Floating-Point Representations and Exceptional Values

Floating-point numbers are stored on Compaq Tru64 UNIX systems in standard IEEE little endian floating-point notation, as follows:

- REAL (KIND=4) or REAL*4 declarations are stored in standard IEEE S_float little endian format.
- REAL (KIND=8) or REAL*8 declarations are stored in standard IEEE T_float little endian format.
- REAL (KIND=16) declarations are stored in Compaq IEEE style X_float binary little endian format.

COMPLEX numbers use a pair of little endian REAL values to denote the real and imaginary parts of the data, as follows:

- COMPLEX (KIND=4) or COMPLEX*8 declarations are stored in IEEE S_float format using two REAL (KIND=4) or REAL*4 values.
- COMPLEX (KIND=8) or COMPLEX*16 declarations are stored in IEEE T_float format using two REAL (KIND=8) or REAL*8 values.
- COMPLEX (KIND=16) or COMPLEX*32 declarations are stored in Compaq IEEE X_float format using two REAL (KIND=16) or REAL*16 values.

All floating-point formats represent fractions in sign-magnitude notation, with the binary radix point to the right of the most-significant bit. Fractions are assumed to be normalized, and therefore the most-significant bit is not stored. This is called hidden bit normalization. The hidden bit is assumed to be 1 unless the exponent is 0. If the exponent equals 0, then the value represented is denormalized (subnormal) or plus or minus 0 (zero).

For an explanation of the representation of NaN, Infinity, and related IEEE exceptional values on Alpha systems, see Section 9.4.8.

## 9.4.1 REAL and COMPLEX Declarations and f90/fort Compiler Options

The default sizes for REAL and COMPLEX data declarations are as follows:

- For REAL data declarations without a kind parameter (or size specifier), the default size is REAL (KIND=4) (same as REAL*4).
- For COMPLEX data declarations without a kind parameter (or size specifier), the default data size is COMPLEX (KIND=4) (same as COMPLEX*8).

To control the size of all REAL or COMPLEX declarations without a kind parameter, use the `f90` command `-real_size nn` , `-r8` , or `-r16` (see Section 3.78).

You can explicitly declare the length of a REAL or a COMPLEX declaration using a kind parameter or specify DOUBLE PRECISION or DOUBLE COMPLEX. To control the size of all DOUBLE PRECISION and DOUBLE COMPLEX declarations, use the `f90` command `-double_size nn` (see Section 3.78).

Intrinsic REAL kinds are 4 (single precision), 8 (double precision), and 16 (extended precision). Intrinsic COMPLEX kinds are also 4 (single precision), 8 (double precision), and 16 (extended precision), such as REAL (KIND=4) for single-precision floating-point data. To obtain the kind of a variable, use the KIND intrinsic function. You can also use a size specifier, such as REAL*4, but be aware this is an extension to the Fortran 95/90 standards.

## 9.4.2 REAL (KIND=4) or REAL*4 Representation

Intrinsic REAL (KIND=4) or REAL*4 (single precision REAL) data occupies four contiguous bytes stored in IEEE S_float format. Bits are labeled from the right, 0 through 31, as shown in Figure 9-6.

Figure 9-6 REAL (KIND=4) or REAL*4 Representation

The form of REAL (KIND=4) or REAL*4 data is sign magnitude, with:

- Bit 31 the sign bit (0 for positive numbers, 1 for negative numbers)
- Bits 30:23 a binary exponent in excess 127 notation
- Bits 22:0 a normalized 24-bit fraction including the redundant most-significant fraction bit not represented

The value of data is in the approximate range: 1.17549435E--38 (normalized) to 3.40282347E38. The IEEE denormalized limit is 1.40129846E--45.

The precision is approximately one part in 2**23, typically seven decimal digits.

## 9.4.3 REAL (KIND=8) or REAL*8 Representation

Intrinsic REAL (KIND=8) or REAL*8 (same as DOUBLE PRECISION) data occupies eight contiguous bytes stored in IEEE T_float format. Bits are labeled from the right, 0 through 63, as shown in Figure 9-7.

Figure 9-7 REAL (KIND=8) or REAL*8 Representation

The form of REAL (KIND=8) or REAL*8 data is sign magnitude, with:

- Bit 63 the sign bit (0 for positive numbers, 1 for negative numbers)
- Bits 62:52 a binary exponent in excess 1023 notation
- Bits 51:0 a normalized 53-bit fraction including the redundant most-significant fraction bit not represented

The value of data is in the approximate range: 2.2250738585072013D-308 (normalized) to 1.7976931348623158D308. The IEEE denormalized limit is 4.94065645841246544D-324.

The precision is approximately one part in 2**52, typically 15 decimal digits.

## 9.4.4 REAL (KIND=16) or REAL*16 Representation

Intrinsic REAL (KIND=16) or REAL*16 (extended precision) data occupies 16 contiguous bytes stored in Compaq IEEE style X_float format. Bits are labeled from the right, 0 through 127, as shown in Figure 9-8.

Figure 9-8 REAL (KIND=16) or REAL*16 Representation

The form of REAL*16 data is sign magnitude, with:

- Bit 127 the sign bit (0 for positive numbers, 1 for negative numbers)
- Bits 126:112 a binary exponent in excess 16383 notation
- Bits 111:0 a normalized 113-bit fraction including the redundant most-significant fraction bit not represented

The value of data is in the approximate range: 6.4751751194380251109244389582276465524996Q-4966 to 1.189731495357231765085759326628007016196477Q4932.

Unlike other floating-point formats, there is little if any performance penalty from using denormalized extended-precision numbers. This is because accessing denormalized REAL (KIND=16) numbers does not result in an arithmetic trap (the extended-precision format is emulated in software). The smallest normalized number is 3.362103143112093506262677817321753Q-4932.

The precision is approximately one part in 2**112 or typically 33 decimal digits.

## 9.4.5 COMPLEX (KIND=4) or COMPLEX*8 Representation

Intrinsic COMPLEX (KIND=4) or COMPLEX*8 (single-precision COMPLEX) data is eight contiguous bytes containing a pair of REAL (KIND=4) or REAL*4 values stored in IEEE S_float format.

The low-order four bytes contain REAL (KIND=4) data that represents the real part of the complex number. The high-order four bytes contain REAL (KIND=4) data that represents the imaginary part of the complex number, as shown in Figure 9-9.

Figure 9-9 COMPLEX (KIND=4) or COMPLEX*8 Representation

The limits and underflow characteristics for REAL (KIND=4) or REAL*4 apply to the two separate real and imaginary parts of a COMPLEX (KIND=4) or COMPLEX*8 number. Like REAL (KIND=4) numbers, the sign bit representation is 0 (zero) for positive numbers and 1 for negative numbers.

## 9.4.6 COMPLEX (KIND=8) or COMPLEX*16 Representation

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) numbers, the sign bit representation is 0 (zero) for positive numbers and 1 for negative numbers.

## 9.4.7 COMPLEX (KIND=16) or COMPLEX*32 Representation

Intrinsic COMPLEX (KIND=16) or COMPLEX*32 (extended precision) data is 32 contiguous bytes containing a pair of REAL*16 values stored in Compaq IEEE style X_float.

The low-order 16 bytes contain REAL (KIND=16) data that represents the real part of the complex data. The high-order 16 bytes contain REAL (KIND=16) data that represents the imaginary part of the complex data, as shown in Figure 9-11.

Figure 9-11 COMPLEX (KIND=16) or COMPLEX*32 Representation

The limits and underflow characteristics for REAL (KIND=16) apply to the two separate real and imaginary parts of a COMPLEX (KIND=16) or COMPLEX*32 number. Like REAL (KIND=16) numbers, the sign bit representation is 0 (zero) for positive numbers and 1 for negative numbers.

For More Information:

- On converting unformatted data, see Chapter 10.
- On defining constants and assigning values to variables, see the Compaq Fortran Language Reference Manual.
- On intrinsic functions related to the various data types, such as SELECTED_REAL_KIND, see the Compaq Fortran Language Reference Manual.
- On VAX (OpenVMS) floating-point data types (provided for those converting OpenVMS data), see Section A.4.3.
- On the `f90` command options that control the size of REAL and COMPLEX declarations (without a kind parameter or size specifier), see Section 3.78.
- On the `f90` command options that control the size of DOUBLE PRECISION declarations, see Section 3.34.
- On IEEE binary floating-point, see ANSI/IEEE Standard 754-1985.

## 9.4.8 Exceptional Floating-Point Representations

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:

- Finite number---A floating-point number that represents a valid number (bit pattern) within the normalized ranges of a particular data type, including --max to --min, --zero, +zero, +min to +max.
  For any native IEEE floating-point data type, the values of min or max are listed in Section 9.4.2 (single precision), Section 9.4.3 (double precision), and Section 9.4.4 (extended precision).
  Special bit patterns that are not finite numbers represent exceptional values.
- Infinity---An IEEE floating-point bit pattern that represents plus or minus infinity. Compaq Fortran identifies infinity values with the letters "Infinity" or asterisks (******) in output statements (depends on field width) or certain hexadecimal values (fraction of 0 and exponent of all 1 values).
- Not-a-Number (NaN)---An IEEE floating-point bit pattern that represents something other than a number. Compaq Fortran identifies NaN values with the letters "NaN" in output statements. A NaN can be a signaling NaN or a quiet NaN:
  - A quiet NaN might occur as a result of a calculation, such as 0./0. and has an exponent of all 1 values and initial fraction bit of 1.
  - A signaling NaN must be set intentionally (does not result from calculations) and has an exponent of all 1 values and initial fraction bit of 0 (with one or more other fraction bits of 1).
- Denormal---Identifies an IEEE floating-point bit pattern that represents a number whose value falls between zero and the smallest finite (normalized) number for that data type. The exponent field contains all zeros.
  For negative numbers, denormalized numbers range from the next representable value larger than minus zero to the representable value that is one bit less than the smallest finite (normalized) negative number. For positive numbers, denormalized numbers range from the next representable value larger than positive zero to the representable value that is one bit less than the smallest finite (normalized) positive number.
- Zero---Can be the value +0 (all zero bits, also called true zero) or -0 (all zero bits except the sign bit, such as Z `'` 8000000000000000 `'` ).

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.44).

Table 9-2 lists the hexadecimal (hex) values of the IEEE exceptional floating-point numbers for S_float (single precision), T_float (double precision), and X_float (extended precision) formats.

Table 9-2 Exceptional Floating-Point Numbers
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 `'`

Compaq Fortran 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 Compaq Fortran 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:

- Continuation when a NaN (or other exceptional value) is encountered in a calculation
- A summary message explaining the number and types of arithmetic exceptions encountered:

      % 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 Compaq Fortran Language Reference Manual and the file `/usr/include/fordef.f` ).

For More Information:

- On using the `f90` command `-fpen` options and the `for_set_fpe` routine to control arithmetic exception handling, see Section 3.44 and Section 14.3.2 respectively.
- On exceptional values, see the Alpha Architecture Reference Manual.
- On IEEE binary floating-point exception handling, see the IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Standard 754-1985) and `ieee(3)`.
- On Compaq Fortran floating-point exception handling, see Chapter 14.

# 9.5 Character Representation

A character string is a contiguous sequence of bytes in memory, as shown in Figure 9-12.

Figure 9-12 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:

- On defining constants, assigning values to variables, using substring expressions, and concatenation, see the Compaq Fortran Language Reference Manual.
- On intrinsic functions related to the various data types, see the Compaq Fortran Language Reference Manual.

# 9.6 Hollerith Representation

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-12).

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:

- On defining constants and assigning values to variables, see the Compaq Fortran Language Reference Manual.
- On intrinsic functions related to the various data types, see the Compaq Fortran Language Reference Manual.

Previous | Next | Contents | Index