shifta

Date:

02-06-2023

NAME

SHIFTA, SHIFTL, SHIFTR - Perform a shift

SYNOPSIS

SHIFTA ([I=]i, [J=]j)
SHIFTL ([I=]i, [J=]j)
SHIFTR ([I=]i, [J=]j)

STANDARDS

Fortran extension

DESCRIPTION

The SHIFTA intrinsic function performs a right shift with sign extension fill of the object i by j.

The SHIFTL intrinsic function performs a left shift with zero fill of i by j bits.

The SHIFTR intrinsic function performs a right shift with zero fill of the i by j bits.

The arguments are as follows:

i

The value to be shifted. Must be of type BOOLEAN, INTEGER, REAL, or Cray pointer.

j

The number of bits to shift the value. Must be of type INTEGER or BOOLEAN. j must be within the range 0 <= j <= size, where size is the size, in bits, of i. That is, if i is a 64-bit object, j must be within the range 0 <= j <= 64.

For values of j outside these ranges, SHIFTA returns an undefined result.

These are elemental functions. The names of these intrinsics cannot be passed as arguments.

NOTES

SHIFTL and SHIFTR are outmoded routines. Refer to the Cray Fortran Reference Manual for information about outmoded features and their preferred standard alternatives.

EXAMPLES

Example 1. The following section of Fortran code shows the SHIFTA function used in the case where i is of type integer. The bit pattern of i and the bit pattern of the result are shown. For clarity, a 16-bit value is used rather than a 64-bit value.

INTEGER I1, I2, I3
I2 = 5
I3 = SHIFTA(I1,I2)

  ---------------------------------------------------------------
 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
  ---------------------------------------------------------------
                                   I1 (i)

  ---------------------------------------------------------------
 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
  ---------------------------------------------------------------
                                       I3 (result)

Example 2. The following section of Fortran code shows the SHIFTL function used in the case where i is of type integer. The bit pattern of i and the bit pattern of the result are also given. For simplicity, a 16-bit object is used.

INTEGER I1, I2, I3
...
I2 = 5
I3 = SHIFTL(I1,I2)

  ---------------------------------------------------------------
 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
  ---------------------------------------------------------------
                           I1 (i)

  ---------------------------------------------------------------
 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
  ---------------------------------------------------------------
                           I3 (result)

Example 3. The following section of Fortran code shows the SHIFTR function used in the case where i is of type integer. The bit pattern of i and the bit pattern of the result are also given. For simplicity, a 16-bit object is used.

INTEGER I1, I2, I3
...
I2 = 5
I3 = SHIFTR(I1,I2)

  ---------------------------------------------------------------
 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
  ---------------------------------------------------------------
                           I1 (i)

  ---------------------------------------------------------------
 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
  ---------------------------------------------------------------
                           I3 (result)