ibchng

Date:

10-12-2011

NAME

IBCHNG, IIBCHNG, JIBCHNG, KIBCHNG, IBCLR, IIBCLR, JIBCLR, KIBCLR, IBSET, IIBSET, JIBSET, KIBSET - Set, clear, or reverse the value of a specified bit in an integer

SYNOPSIS

IBCHNG ([I=]i [,POS=]pos)
IIBCHNG ([I=]i [,POS=]pos)
JIBCHNG ([I=]i [,POS=]pos)
KIBCHNG ([I=]i [,POS=]pos)
IBCLR ([I=]i [,POS=]pos)
IIBCLR ([I=]i [,POS=]pos)
JIBCLR ([I=]i [,POS=]pos)
KIBCLR ([I=]i [,POS=]pos)
IBSET ([I=]i [,POS=]pos)
IIBSET ([I=]i [,POS=]pos)
JIBSET ([I=]i [,POS=]pos)
KIBSET ([I=]i [,POS=]pos)

IMPLEMENTATION

Cray Linux Environment (CLE)

STANDARDS

Fortran

Fortran extensions: IBCHNG, IIBCHNG, JIBCHNG, KIBCHNG, IIBCLR, JIBCLR, KIBCLR, IIBSET, JIBSET, KIBSET

DESCRIPTION

The IBCHNG, IIBCHNG, JIBCHNG, and KIBCHNG intrinsic functions reverse the value of a specified bit in an integer.

The IBCLR, IIBCLR, JIBCLR, and KIBCLR intrinsic functions clear one bit to zero.

The IBSET, IIBSET, JIBSET, and KIBSET intrinsic functions set one bit to 1.

They accept the following arguments:

i

Must be of type integer.

  • For IBCHNG, IIBCHNG, JIBCHNG, and KIBCHNG, i contains the bit to be reversed.

  • For IIBCHNG, must be of type integer (KIND=2).

  • For JIBCHNG, must be of type integer (KIND=4).

  • For KIBCHNG, must be of type integer (KIND=8).

  • For IIBCLR, must be of type integer (KIND=2).

  • For JIBCLR, must be of type integer (KIND=4).

  • For KIBCLR, must be of type integer (KIND=8).

  • For IIBSET, must be of type integer (KIND=2).

  • For JIBSET, must be of type integer (KIND=4).

  • For KIBSET, must be of type integer (KIND=8).

pos

Must be of type integer.

  • For IBCHNG, IIBCHNG, JIBCHNG, and KIBCHNG, i specifies the position of the bit to be reversed. The rightmost (least significant) bit of i is in position 0.

  • For IBCLR, IIBCLR, JIBCLR, KIBCLR, IBSET, IIBSET, JIBSET, and KIBSET, pos must be nonnegative and less than BIT_SIZE (i).

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

RETURN VALUES

For IBCHNG, IIBCHNG, JIBCHNG, and KIBCHNG, the result type and type parameter are the same as i. The result is equal to i, with the bit in position pos reversed.

For IBCLR, IIBCLR, JIBCLR, and KIBCLR, the result type and type parameter are the same as i. The result has the value of the sequence of bits of i, except that bit pos of i is set to zero.

For IBSET, IIBSET, JIBSET, KIBSET, the result type and type parameter are the same as i. The result has the value of the sequence of bits of i, except that bit pos of i is set to one.

The bit model defines the interpretation of an integer value as a sequence of bits. For more information on the bit model, see the models(3i) man page.

EXAMPLES

Example 1. IBCLR(14,1) yields 12.

Example 2. If V has the value [1,2,3,4], IBCLR(I=31 ,POS=V) yields [29,27,23,15].

Example 3. IBSET(12,1) yields 14.

Example 4. If V has the value [1,2,3,4], IBSET(I=0, POS=V) yields [2,4,8,16].

SEE ALSO

models(3i)