A typeless constant does not have an intrinsic type. 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.
The form of a hexadecimal constant is:
>>-+--+-X-+---+-'--hexadecimal_number--'--+-+------------------>< | '-Z-' '-"--hexadecimal_number--"--' | +--+-'--hexadecimal_number--'--+---+-X-+-+ | '-"--hexadecimal_number--"--' '-Z-' | '-Z--hexadecimal_number------------------' |
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.
Z'0123456789ABCDEF' Z"FEDCBA9876543210 Z'0123456789aBcDeF' Z0123456789aBcDeF ! This form can only be used as an initialization value
The form of an octal constant is:
>>-+-O--+-'--octal_number--'--+----+--------------------------->< | '-"--octal_number--"--' | '--+-'--octal_number--'--+---O--' '-"--octal_number--"--' |
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.
O'01234567' "01234567"O
The form of a binary constant is:
>>-+-B--+-'--binary_number--'--+----+-------------------------->< | '-"--binary_number--"--' | '--+-'--binary_number--'--+---B--' '-"--binary_number--"--' |
If 8x binary digits are present, x bytes are represented.
See Using Typeless Constants for information on how XL Fortran interprets the constant.
B"10101010" '10101010'B
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.
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.
the reference to the generic name will be resolved through the specific procedure.
the typeless constant is converted to default integer. If a specific intrinsic function takes integer arguments, the reference is resolved through that specific function. If there are no specific intrinsic functions, the reference is resolved through the generic function.
the typeless constant assumes the type of that argument. The selected specific intrinsic procedure is based on that type.
INTERFACE SUB SUBROUTINE SUB1( A ) REAL A END SUBROUTINE SUBROUTINE SUB2( A, B ) REAL A, B END SUBROUTINE SUBROUTINE SUB3( I ) INTEGER I END SUBROUTINE END INTERFACE CALL SUB('C0600000'X, '40066666'X) ! Resolves to SUB2 CALL SUB('00000000'X) ! Invalid - ambiguous, may ! resolve to either SUB1 or SUB3
the constant assumes the default integer size but no data type, unless it is a Hollerith constant. The default for passing a Hollerith constant is the same as if it were a character actual argument. See Resolution of Procedure References for more information about establishing a procedure name to be generic or specific.
the constant is passed as if it were a default integer for hexadecimal, binary, and octal constants.
If the constant is a Hollerith constant and it is smaller than the size of a default integer, XL Fortran adds blanks on the right. If the constant is a Hollerith constant and it is larger than 8 bytes, XL Fortran truncates the rightmost Hollerith characters. See Resolution of Procedure References for more information about establishing a procedure name to be generic or specific.
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.