HP Fortran for OpenVMS
Language Reference Manual


Previous Contents Index

9.4.66 IDATE (I, J, K)

Description: Returns three integer values representing the current month, day, and year.
Class: Subroutine
Arguments: I is the current month.
  J is the current day.
  K is the current year.

Warning: The two-digit year return value may cause problems with the year 2000. Use DATE_AND_TIME instead (see Section 9.4.36).

Note: If time-zone information is not available on the system, a blank is returned for the ZONE argument and --1 is returned for the differential element of the VALUES argument.

Examples

If the current date is September 16, 1996, the values of the integer variables upon return are: I = 9, J = 16, and K = 96.

9.4.67 IEOR (I, J)

Description: Performs an exclusive OR on corresponding bits. 1
Class: Elemental function; Generic
Arguments: I Must be of type integer.
  J Must be of type integer with the same kind parameter as I.
Results: The result type is the same as I. The result value is derived by combining I and J bit-by-bit according to the following truth table:
I
J
IEOR (I, J)

1 1 0
1 0 1
0 1 1
0 0 0

The model for the interpretation of an integer value as a sequence of bits is shown in Section D.3.


1This function can also be specified as XOR.

Specific Name Argument Type Result Type
  INTEGER(1) INTEGER(1)
IIEOR INTEGER(2) INTEGER(2)
JIEOR INTEGER(4) INTEGER(4)
KIEOR INTEGER(8) INTEGER(8)

Examples

IEOR (1, 4) has the value 5.

IEOR (3, 10) has the value 9.

9.4.68 ILEN (I)

Description: Returns the length (in bits) of the two's complement representation of an integer.
Class: Elemental function; Generic
Arguments: I must be of type integer.
Results: The result type is the same as I. The result value is (LOG 2( I + 1 )) if I is not negative; otherwise, the result value is (LOG 2( -I )).

Examples

ILEN (4) has the value 3.

ILEN (--4) has the value 2.

9.4.69 INDEX (STRING, SUBSTRING [,BACK] [,KIND])

Description: Returns the starting position of a substring within a string.
Class: Elemental function; Generic
Arguments: STRING Must be of type character.
  SUBSTRING Must be of type character.
  BACK (opt) Must be of type logical.
  KIND (opt) Must be a scalar integer initialization expression.
Results: The result is of type integer. If KIND is present, the kind parameter of the result is that specified by KIND; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the result value in the kind of the result, the result is undefined.

If BACK is absent or false, the value returned is the minimum value of I such that STRING (I : I + LEN (SUBSTRING) - 1) = SUBSTRING (or zero if there is no such value). If LEN (STRING) < LEN (SUBSTRING), zero is returned. If LEN (SUBSTRING) = zero, 1 is returned.

If BACK is true, the value returned is the maximum value of I such that STRING (I : I + LEN (SUBSTRING) - 1) = SUBSTRING (or zero if there is no such value). If LEN(STRING) < LEN (SUBSTRING), zero is returned. If LEN (SUBSTRING) = zero, LEN (STRING) + 1 is returned.

Specific Name Argument Type Result Type
INDEX CHARACTER INTEGER(4)
  CHARACTER INTEGER(8)

Examples

INDEX ( ' FORTRAN ' , ' O ' , BACK = .TRUE.) has the value 2.

INDEX ( ' XXXX ' , "-", BACK = .TRUE.) has the value 0.

INDEX ( ' XXXX ' , " ", BACK = .TRUE.) has the value 5.

9.4.70 INT (A [,KIND])

Description: Converts a value to integer type.
Class: Elemental function; Generic
Arguments: A Must be of type integer, real, or complex.
  KIND (opt) Must be a scalar integer initialization expression.
Results: The result is of type integer. If KIND is present, the kind parameter of the result is that specified by KIND; otherwise, the kind parameter of the result is that shown in the following table. If the processor cannot represent the result value in the kind of the result, the result is undefined.

Functions that cause conversion of one data type to another type have the same effect as the implied conversion in assignment statements.

The result value depends on the type and absolute value of A:

  • If A is of type integer, INT (A) = A.
  • If A is of type real and |A| < 1, INT (A) has the value zero.

    If A is of type real and |A| >= 1, INT (A) is the integer whose magnitude is the largest integer that does not exceed the magnitude of A and whose sign is the same as the sign of A.

  • If A is of type complex, INT (A) = A is the value obtained by applying the preceding rules (for a real argument) to the real part of A.

The setting of compiler options specifying integer size can affect INT, IDINT, and IQINT.

The setting of compiler options specifying integer size or real size can affect IFIX.

Specific Name1 Argument Type Result Type
  INTEGER(1), INTEGER(2), INTEGER(4) INTEGER(4)
  INTEGER(1), INTEGER(2), INTEGER(4), INTEGER(8) INTEGER(8)
IIFIX 2 REAL(4) INTEGER(2)
IINT REAL(4) INTEGER(2)
IFIX 3 REAL(4) INTEGER(4)
JFIX INTEGER(1), INTEGER(2), INTEGER(4), INTEGER(8), REAL(4), REAL(8), REAL(16), COMPLEX(4), COMPLEX(8), COMPLEX(16) INTEGER(4)
INT 4 REAL(4) INTEGER(4)
KIFIX REAL(4) INTEGER(8)
KINT REAL(4) INTEGER(8)
IIDINT REAL(8) INTEGER(2)
IDINT 5 REAL(8) INTEGER(4)
KIDINT REAL(8) INTEGER(8)
IIQINT REAL(16) INTEGER(2)
IQINT 6 REAL(16) INTEGER(4)
KIQINT REAL(16) INTEGER(8)
  COMPLEX(4), COMPLEX(8), COMPLEX(16) INTEGER(2)
  COMPLEX(4), COMPLEX(8), COMPLEX(16) INTEGER(4)
  COMPLEX(4), COMPLEX(8), COMPLEX(16) INTEGER(8)
INT1 INTEGER(1), INTEGER(2), INTEGER(4), INTEGER(8), REAL(4), REAL(8), REAL(16), COMPLEX(4), COMPLEX(8), COMPLEX(16) INTEGER(1)
INT2 INTEGER(1), INTEGER(2), INTEGER(4), INTEGER(8), REAL(4), REAL(8), REAL(16), COMPLEX(4), COMPLEX(8), COMPLEX(16) INTEGER(2)
INT4 INTEGER(1), INTEGER(2), INTEGER(4), INTEGER(8), REAL(4), REAL(8), REAL(16), COMPLEX(4), COMPLEX(8), COMPLEX(16) INTEGER(4)
INT8 INTEGER(1), INTEGER(2), INTEGER(4), INTEGER(8), REAL(4), REAL(8), REAL(16), COMPLEX(4), COMPLEX(8), COMPLEX(16) INTEGER(8)


1These specific functions cannot be passed as actual arguments.
2This function can also be specified as HFIX.
3For compatibility with older versions of Fortran, IFIX can also be specified as a generic function.
4Or JINT.
5Or JIDINT. For compatibility with older versions of Fortran, IDINT can also be specified as a generic function.
6Or JIQINT. For compatibility with older versions of Fortran, IQINT can also be specified as a generic function.

Examples

INT (--4.2) has the value --4.

INT (7.8) has the value 7.

9.4.71 INT_PTR_KIND( )

Description: Returns the INTEGER KIND that will hold an address. This is a specific function that has no generic function associated with it. It must not be passed as an actual argument.
Class: Inquiry function; Specific
Arguments: None.
Results: The result is of type default integer. The result is a scalar with the value equal to the value of the kind parameter of the integer data type that can represent an address on the host platform.

The value is 8.

Examples

Consider the following:


REAL A(100) 
POINTER (P, A) 
INTEGER (KIND=INT_PTR_KIND()) SAVE_P 
P = MALLOC (400) 
SAVE_P = P 

9.4.72 IOR (I, J)

Description: Performs an inclusive OR on corresponding bits. 1
Class: Elemental function; Generic
Arguments: I Must be of type integer.
  J Must be of type integer with the same kind parameter as I.
Results: The result type is the same as I. The result value is derived by combining I and J bit-by-bit according to the following truth table:
I
J
IOR (I, J)

1 1 1
1 0 1
0 1 1
0 0 0

The model for the interpretation of an integer value as a sequence of bits is shown in Section D.3.


1This function can also be specified as OR.

Specific Name Argument Type Result Type
  INTEGER(1) INTEGER(1)
IIOR INTEGER(2) INTEGER(2)
JIOR INTEGER(4) INTEGER(4)
KIOR INTEGER(8) INTEGER(8)

Examples

IOR (1, 4) has the value 5.

IOR (1, 2) has the value 3.

9.4.73 ISHA (I, SHIFT)

Description: Arithmetically shifts an integer left or right by a specified number of bits.
Class: Elemental function; Generic
Arguments: I Must be of type integer. This argument is the value to be shifted.
  SHIFT Must be of type integer. This argument is the direction and distance of shift.

Positive shifts are left (toward the most significant bit); negative shifts are right (toward the least significant bit).

Results: The result type is the same as I. The result is equal to I shifted arithmetically by SHIFT bits.

If SHIFT is positive, the shift is to the left; if SHIFT is negative, the shift is to the right. If SHIFT is zero, no shift is performed.

Bits shifted out from the left or from the right, as appropriate, are lost. If the shift is to the left, zeros are shifted in on the right. If the shift is to the right, copies of the sign bit (0 for non-negative I; 1 for negative I) are shifted in on the left.

The kind of integer is important in arithmetic shifting because sign varies among integer representations (see the following example). If you want to shift a one-byte or two-byte argument, you must declare it as INTEGER(1) or INTEGER(2).

Examples

Consider the following:


INTEGER(1) i, res1 
INTEGER(2) j, res2 
i = -128             ! equal to  10000000 
j = -32768           ! equal to  10000000 00000000 
res1  = ISHA (i, -4) ! returns 11111000 = -8 
res2  = ISHA (j, -4) ! returns 11111000 00000000 = -2048 

9.4.74 ISHC (I, SHIFT)

Description: Rotates an integer left or right by specified number of bits. Bits shifted out one end are shifted in the other end. No bits are lost.
Class: Elemental function; Generic
Arguments: I Must be of type integer. This argument is the value to be rotated.
  SHIFT Must be of type integer. This argument is the direction and distance of rotation.

Positive rotations are left (toward the most significant bit); negative rotations are right (toward the least significant bit).

Results: The result type is the same as I. The result is equal to I circularly rotated by SHIFT bits.

If SHIFT is positive, I is rotated left SHIFT bits. If SHIFT is negative, I is rotated right SHIFT bits. Bits shifted out one end are shifted in the other. No bits are lost.

The kind of integer is important in circular shifting. With an INTEGER(4) argument, all 32 bits are shifted. If you want to rotate a one-byte or two-byte argument, you must declare it as INTEGER(1) or INTEGER(2).

Examples

Consider the following:


INTEGER(1) i, res1 
INTEGER(2) j, res2 
i = 10                 ! equal to  00001010 
j = 10                 ! equal to  00000000 00001010 
res1  = ISHC (i, -3)   ! returns 01000001 =  65 
res2  = ISHC (j, -3)   ! returns 01000000 00000001 = 16385 

9.4.75 ISHFT (I, SHIFT)

Description: Performs a logical shift.
Class: Elemental function; Generic
Arguments: I Must be of type integer.
  SHIFT Must be of type integer. The absolute value for SHIFT must be less than or equal to BIT_SIZE (I).
Results: The result type is the same as I. The result has the value obtained by shifting the bits of I by SHIFT positions. If SHIFT is positive 1, the shift is to the left; if SHIFT is negative 2, the shift is to the right. If SHIFT is zero, no shift is performed.

Bits shifted out from the left or from the right, as appropriate, are lost. Zeros are shifted in from the opposite end.

The model for the interpretation of an integer value as a sequence of bits is shown in Section D.3. For more information on bit functions, see Section 9.3.3.


1ISHFT with a positive SHIFT can also be specified as LSHIFT.
2ISHFT with a negative SHIFT can also be specified as RSHIFT with |SHIFT|.

Specific Name Argument Type Result Type
  INTEGER(1) INTEGER(1)
IISHFT INTEGER(2) INTEGER(2)
JISHFT INTEGER(4) INTEGER(4)
KISHFT INTEGER(8) INTEGER(8)

Examples

ISHFT (2, 1) has the value 4.

ISHFT (2, --1) has the value 1.


Previous Next Contents Index