# Logical Data Representations

Logical data can be 1, 2, 4, or 8 bytes in length.

The default data size used for a LOGICAL data declaration is LOGICAL(4) (same as LOGICAL(KIND=4)). However, you can specify a compiler option to override the default. Option integer-size 16 can be used to specify LOGICAL(2) and option integer-size 64 can be used to specify LOGICAL(8).

To improve performance on systems using Intel® 64 architecture, use LOGICAL(4) (or LOGICAL(8)) rather than LOGICAL(2) or LOGICAL(1). On systems using IA-32 architecture, use LOGICAL(4) rather than LOGICAL(8), LOGICAL(2), or LOGICAL(1).

LOGICAL(KIND=1) values are stored in 1 byte. In addition to having logical values .TRUE. and .FALSE., LOGICAL(1) data can also have values in the range -128 to 127. Logical variables can also be interpreted as integer data.

In addition to LOGICAL(1), logical values can also be stored in 2 (LOGICAL(2)), 4 (LOGICAL(4)), or 8 (LOGICAL(8)) contiguous bytes, starting on an arbitrary byte boundary.

The Intel® Fortran compilers permit a numerical value to be assigned to a logical variable. The internal representation of the numerical value used to be assigned to the logical variable with no change in the internal representation. Now, by default, the value is converted to the internal representation of .true. or .false. and the converted value is stored into the logical variable. To change the behavior to the old semantics, specify assume old_logical_assign on the command line.

If the fpscomp nologicals compiler option is set (the default), the low-order bit determines whether the logical value is true or false. To interoperate with procedures written in C for Microsoft* Fortran PowerStation logical values, where 0 (zero) is false and non-zero values are true, specify fpscomp logicals.

LOGICAL(1), LOGICAL(2), LOGICAL(4), and LOGICAL(8) data representations (when fpscomp nologicals is set) appear below.

The symbol :A in the figure specifies the address of the byte containing bit 0, which is the starting address of the represented data element.

LOGICAL(1), LOGICAL(2), LOGICAL(4), and LOGICAL(8) Data Representations
Parent topic: Data Representation Overview

## See Also

integer-size compiler option
assume compiler option, setting [no]old_logical_assign
fpscomp compiler option, setting [no]logicals