Sun Studio 12: Fortran User's Guide

4.5 Unsigned Integers

The Fortran 95 compiler accepts a new data type, UNSIGNED, as an extension to the language. Four KIND parameter values are accepted with UNSIGNED: 1, 2, 4, and 8, corresponding to 1-, 2-, 4-, and 8-byte unsigned integers, respectively.

The form of an unsigned integer constant is a digit-string followed by the upper or lower case letter U, optionally followed by an underscore and kind parameter. The following examples show the maximum values for unsigned integer constants:


Expressed without a kind parameter (12345U), the default is the same as for default integer. This is U_4 but can be changed by the -xtypemap option, which will change the kind type for default unsigned integers.

Declare an unsigned integer variable or array with the UNSIGNED type specifier:

        UNSIGNED U
        UNSIGNED(KIND=2) :: A
        UNSIGNED*8 :: B

4.5.1 Arithmetic Expressions

4.5.2 Relational Expressions

Signed and unsigned integer operands may be compared using intrinsic relational operations. The result is based on the unaltered value of the operands.

4.5.3 Control Constructs

4.5.4 Input/Output Constructs

4.5.5 Intrinsic Functions