Fortran User's Guide

Boolean Type

f90 supports constants and expressions of Boolean type. There are no Boolean variables or arrays, and there is no Boolean type statement.

Miscellaneous Rules Governing Boolean Type

Alternate Forms of Boolean Constants

f90 allows a Boolean constant (octal, hexadecimal, or Hollerith) in the following alternate forms (no binary). Variables cannot be declared Boolean. Standard Fortran does not allow these forms.

Octal

ddddddB, where d is any octal digit

Within an I/O format specification, the letter B indicates binary digits; elsewhere it indicates octal digits.

Hexadecimal

X'ddd' or X"ddd", where d is any hexadecimal digit

Hollerith

Accepted forms for Hollerith data are:

nH...

'...'H

"..."H

nL...

'...'L

"..."L

nR...

'...'R

"..."R

Above, "..." is a string of characters and n is the character count.

Examples: Octal and hexadecimal constants.

Boolean Constant 

Internal Octal for 32-bit word 

 0B 00000000000
 77740B 00000077740
 X"ABE" 00000005276
 X"-340" 37777776300
 X'1 2 3' 00000000443
 X'FFFFFFFFFFFFFFFF' 37777777777

Examples: Octal and hexadecimal in assignment statements.

 i = 1357B
 j = X"28FF"
 k = X'-5A'

Use of an octal or hexadecimal constant in an arithmetic expression can produce undefined results and do not generate syntax errors.

Alternate Contexts of Boolean Constants

f90 allows BOZ constants in the places other than DATA statements.

B'bbb'

O'ooo'

Z'zzz'

B"bbb"

O"ooo"

Z"zzz"

If these are assigned to a real variable, no type conversion occurs.

Standard Fortran allows these only in DATA statements.