XL Fortran for AIX 8.1

Language Reference

+-------------------------------IBM Extension--------------------------------+


Typeless Literal Constants

A typeless constant does not have an intrinsic type in XL Fortran. Hexadecimal, octal, binary, and Hollerith constants can be used in any situation where intrinsic literal constants are used, except as the length specification in a type declaration statement (although typeless constants can be used in a type_param_value in CHARACTER type declaration statements). The number of digits recognized in a hexadecimal, octal, or binary constant depends on the context in which the constant is used.

Hexadecimal Constants

The form of a hexadecimal constant is:



>>-+-+-X-+--+-'--hexadecimal_number--'-+-+---------------------><
   | '-Z-'  '-"--hexadecimal_number--"-' |
   +-+-'--hexadecimal_number--'-+--+-X-+-+
   | '-"--hexadecimal_number--"-'  '-Z-' |
   '-Z--hexadecimal_number---------------'
 
 

hexadecimal_number
is a string composed of digits (0-9) and letters (A-F, a-f). Corresponding uppercase and lowercase letters are equivalent.

The Znn...nn form of a hexadecimal constant can only be used as a data initialization value delimited by slashes. If this form of a hexadecimal constant is the same string as the name of a constant you defined previously with the PARAMETER attribute, XL Fortran recognizes the string as the named constant.

If 2x hexadecimal digits are present, x bytes are represented.

See Using Typeless Constants for information on how XL Fortran interprets the constant.

Examples of Hexadecimal Constants

Z'0123456789ABCDEF'
Z"FEDCBA9876543210
Z'0123456789aBcDeF'
Z0123456789aBcDeF   ! This form can only be used as an initialization value

Octal Constants

The form of an octal constant is:



>>-+-O--+-'--octal_number--'-+-+-------------------------------><
   |    '-"--octal_number--"-' |
   '-+-'--octal_number--'-+--O-'
     '-"--octal_number--"-'
 
 

octal_number
is a string composed of digits (0-7)

Because an octal digit represents 3 bits, and a data object represents a multiple of 8 bits, the octal constant may contain more bits than are needed by the data object. For example, an INTEGER(2) data object can be represented by a 6-digit octal constant if the leftmost digit is 0 or 1; an INTEGER(4) data object can be represented by an 11-digit constant if the leftmost digit is 0, 1, 2, or 3; an INTEGER(8) can be represented by a 22-digit constant if the leftmost digit is 0 or 1.

See Using Typeless Constants for information on how the constant is interpreted by XL Fortran.

Examples of Octal Constants

O'01234567'
"01234567"O

Binary Constants

The form of a binary constant is:



>>-+-B--+-'--binary_number--'-+-+------------------------------><
   |    '-"--binary_number--"-' |
   '-+-'--binary_number--'-+--B-'
     '-"--binary_number--"-'
 
 

binary_number
is a string formed from the digits 0 and 1

If 8x binary digits are present, x bytes are represented.

See Using Typeless Constants for information on how XL Fortran interprets the constant.

Examples of Binary Constants

B"10101010"
'10101010'B

Hollerith Constants

The form of a Hollerith constant is:



>>-n--H--character_string--------------------------------------><
 
 

A Hollerith constant consists of a nonempty string of characters capable of representation in the processor and preceded by nH, where n is a positive unsigned integer constant representing the number of characters after the H. n cannot specify a kind type parameter. The number of characters in the string may be from 1 to 255.

Note:
If you specify nH and fewer than n characters are specified after the n, any blanks that are used to extend the input line to the right margin are considered to be part of the Hollerith constant. A Hollerith constant can be continued on a continuation line. At least n characters must be available for the Hollerith constant.

XL Fortran also recognizes escape sequences in Hollerith constants, unless the -qnoescape compiler option is specified. If a Hollerith constant contains an escape sequence, n is the number of characters in the internal representation of the string, not the number of characters in the source string. (For example, 2H\"\" represents a Hollerith constant for two double quotation marks.)

XL Fortran provides support for multibyte characters within character constants, Hollerith constants, H edit descriptors, character-string edit descriptors, and comments. This support is provided through the -qmbcs option. Assignment of a constant containing multibyte characters to a variable that is not large enough to hold the entire string may result in truncation within a multibyte character.

Support is also provided for Unicode characters and filenames. If the environment variable LANG is set to UNIVERSAL and the -qmbcs compiler option is specified, the compiler can read and write Unicode characters and filenames.

See Using Typeless Constants for information on how the constant is interpreted by XL Fortran.

Using Typeless Constants

The data type and length of a typeless constant are determined by the context in which you use the typeless constant. XL Fortran does not convert them before use.

Examples of Typeless Constants in Expressions

INT=B'1'          ! Binary constant is default integer
RL4=X'1'          ! Hexadecimal constant is default real
INT=INT + O'1'    ! Octal constant is default integer
RL4=INT + B'1'    ! Binary constant is default integer
INT=RL4 + Z'1'    ! Hexadecimal constant is default real
ARRAY(O'1')=1.0   ! Octal constant is default integer
 
LOGICAL(8) LOG8
LOG8=B'1'         ! Binary constant is LOGICAL(8), LOG8 is .TRUE.

+----------------------------End of IBM Extension----------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]