• No results found

Data Representation

In document Intel Fortran Compiler User Guide (Page 171-181)

Data Representation Overview

Intel®Fortran expects numeric data to be in native little endian order, in which the least-significant,

right-most zero bit (bit 0) or byte has a lower address than the most-significant, left-most bit (or byte). For information on using nonnative big endian and VAX* floating-point formats, seeSupported Native and Nonnative Numeric Formats.

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

The following table lists the intrinsic data types used by Intel®Fortran, the storage required, and

valid ranges. For information on declaring Fortran intrinsic data types, seeType Declaration Statements. For example, the declaration INTEGER(4) is the same as INTEGER(KIND=4) and INTEGER*4.

Table 21: Fortran Data Types and Storage

Description Storage

Data Type

A BYTE declaration is a signed integer data type equivalent to INTEGER(1).

1 byte (8 bits) BYTE

INTEGER(1)

Signed integer, either INTEGER(2), INTEGER(4), or INTEGER(8). The size is controlled by the-integer-size(Linux* OS and Mac OS* X) or/integer-size(Windows* OS) compiler option. See INTEGER(2), INTEGER(4), and INTEGER(8) INTEGER

Signed integer value from -128 to 127. 1 byte

(8 bits) INTEGER(1)

Signed integer value from -32,768 to 32,767. 2 bytes

(16 bits) INTEGER(2)

Signed integer value from -2,147,483,648 to 2,147,483,647. 4 bytes

Description Storage

Data Type

Signed integer value from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

8 bytes (64 bits) INTEGER(8)

Real floating-point values, either REAL(4), REAL(8), or REAL(16). The size is controlled by the-real-size(Linux OS and Mac OS X) or/real-size(Windows) compiler option.

See REAL(4), REAL(8) and REAL(16). REAL

Single-precision real floating-point values in IEEE S_floating format ranging from 1.17549435E-38 to 3.40282347E38. Values between 1.17549429E-38 and 1.40129846E-45 are denormalized (subnormal).

4 bytes (32 bits) REAL(4)

Double-precision real floating-point values in IEEE T_floating format ranging from 2.2250738585072013D-308 to

1.7976931348623158D308. Values between

2.2250738585072008D-308 and 4.94065645841246544D-324 are denormalized (subnormal).

8 bytes (64 bits) REAL(8)

Extended-precision real floating-point values in IEEE-style X_floating format ranging from

6.4751751194380251109244389582276465524996Q-4966 to 1.189731495357231765085759326628007016196477Q4932. 16 bytes

(128 bits) REAL(16)

Complex floating-point values in a pair of real and imaginary parts that are either REAL(4), REAL(8), or REAL(16). The size is controlled by the-real-size(Linux OS and Mac OS X) or

/real-size(Windows OS) compiler option. See COMPLEX(4), COMPLEX(8) and COMPLEX(16). COMPLEX

Single-precision complex floating-point values in a pair of IEEE S_floating format parts: real and imaginary. The real and imaginary parts each range from 1.17549435E-38 to 3.40282347E38. Values between 1.17549429E-38 and 1.40129846E-45 are denormalized (subnormal). 8 bytes

(64 bits) COMPLEX(4)

Double-precision complex floating-point values in a pair of IEEE T_floating format parts: real and imaginary. The real and imaginary parts each range from 2.2250738585072013D-308 16 bytes

(128 bits) COMPLEX(8)

DOUBLE COMPLEX

Description Storage

Data Type

to 1.7976931348623158D308. Values between

2.2250738585072008D-308 and 4.94065645841246544D-324 are denormalized (subnormal).

Extended-precision complex floating-point values in a pair of IEEE-style X_floating format parts: real and imaginary. The real and imaginary parts each range from

6.4751751194380251109244389582276465524996Q-4966 to 1.189731495357231765085759326628007016196477Q4932. 32 bytes

(256 bits) COMPLEX(16)

Logical value, either LOGICAL(2), LOGICAL(4), or LOGICAL(8). The size is controlled by the-integer-size(Linux OS and Mac OS X) or/integer-size(Windows OS) compiler option. See LOGICAL(2), LOGICAL(4), and LOGICAL(8). LOGICAL

Logical values .TRUE. or .FALSE. 1 byte

(8 bits) LOGICAL(1)

Logical values .TRUE. or .FALSE. 2 bytes

(16 bits) LOGICAL(2)

Logical values .TRUE. or .FALSE. 4 bytes

(32 bits) LOGICAL(4)

Logical values .TRUE. or .FALSE. 8 bytes

(64 bits) LOGICAL(8)

Character data represented by character code convention.

Character declarationscan be in the form CHARACTER(LEN=n) or CHARACTER*n, where n is the number of bytes or n is (*) to indicate passed-length format.

1 byte (8 bits) per character CHARACTER Hollerith constants. 1 byte (8 bits) per Hollerith character HOLLERITH

In addition, you can definebinary (bit) constants. See these topics:

See Also

• Data Representation

• Integer Data Representations • Logical Data Representations • Character Representation • Hollerith Representation

Integer Data Representations

Integer Data Representations Overview

The Fortran numeric environment is flexible, which helps make Fortran a strong language for intensive numerical calculations. The Fortran standard purposely leaves the precision of numeric quantities and the method of rounding numeric results unspecified. This allows Fortran to operate efficiently for diverse applications on diverse systems.

The effect of math computations on integers is straightforward:

• Integers of KIND=1consist of a maximum positive integer (127), a minimum negative integer (-128), and all integers between them including zero.

• Integers of KIND=2consist of a maximum positive integer (32,767), a minimum negative integer (-32,768) , and all integers between them including zero.

• Integers of KIND=4consist of a maximum positive integer (2,147,483,647), a minimum negative integer (-2,147,483,648), and all integers between them including zero.

• Integers of KIND=8consist of a maximum positive integer (9,223,372,036,854,775,807), a minimum negative integer (-9,223,372,036,854,775,808), and all integers between them including zero.

Operations on integers usually result in other integers within this range. Integer computations that produce values too large or too small to be represented in the desired KIND result in the loss of precision. One arithmetic rule to remember is that integer division results in truncation (for example, 8/3 evaluates to 2).

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

The default data size used for an INTEGER data declaration is INTEGER(4) (same as

INTEGER(KIND=4), unless the-integer-size 16(Linux* OS and Mac OS* X) or/integer- size:16(Windows*OS) or the-integer-size 64(Linux OS and Mac OS X) or/integer- size:64(Windows OS) option was specified.

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

INTEGER(KIND=1) Representation

INTEGER(1) values range from -128 to 127 and are stored in 1 byte, as shown below.

Figure 1: INTEGER(1) Data Representation

Integers are stored in a two's complement representation. For example:

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

INTEGER(KIND=2) Representation

INTEGER(2) values range from -32,768 to 32,767 and are stored in 2 contiguous bytes, as shown below:

Figure 2: INTEGER(2) Data Representation

Integers are stored in a two's complement representation. For example:

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

INTEGER(KIND=4) Representation

INTEGER(4) values range from -2,147,483,648 to 2,147,483,647 and are stored in 4 contiguous bytes, as shown below.

Figure 3: INTEGER(4) Data Representation

Integers are stored in a two's complement representation.

INTEGER(KIND=8) Representation

INTEGER(8) values range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 and are stored in 8 contiguous bytes, as shown below.

Figure 4: INTEGER(8) Data Representation

Integers are stored in a two's complement representation.

Logical Data Representations

Logical data lengths 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)), unless-integer-size 16or-integer-size 64(Linux OS and Mac OS X) or/integer-size:16or/integer-size:64(Windows OS) was specified.

To improve performance on systems using Intel®64 architecture and IA-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.

If the-fpscomp nological(Linux OS and Mac OS X) or/fpscomp:nological(Windows OS) compiler option is set (the default), the low-order bit determines whether the logical value is true or false. Specifylogicalinstead ofnologicalfor Microsoft* Fortran PowerStation logical values, where 0 (zero) is false and non-zero values are true.

LOGICAL(1), LOGICAL(2), LOGICAL(4), and LOGICAL(8) data representation (whennological

is specified) appears below.

Character Representation

A character string is a contiguous sequence of bytes in memory, as shown below.

Figure 6: 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. For Windows* OS, the length L of a string is in the range 1 through 2,147,483,647 (2**31-1) . For Linux* OS, the length L of a string is in the range 1 through 2,147,483,647 (2**31-1) for systems based on IA-32 architecture and in the range 1 through 9,223,372,036,854,775,807 (2**63-1) for systems based on Intel®64 architecture

Hollerith Representation

In document Intel Fortran Compiler User Guide (Page 171-181)