Intel® Fortran Compiler 16.0 User and Reference Guide

IBCHNG

Elemental Intrinsic Function (Generic): Reverses the value of a specified bit in an integer.

result = IBCHNG (i,pos)

i

(Input) Must be of type integer or of type logical (which is treated as an integer). This argument contains the bit to be reversed.

pos

(Input) Must be of type integer. This argument is the position of the bit to be changed.

The rightmost (least significant) bit of i is in position 0.

Results

The result type and kind is the same as i. The result is equal to i with the bit in position pos reversed.

For more information, see Bit Functions.

Example

  INTEGER J, K
  J = IBCHNG(10, 2)     ! returns 14 = 1110
  K = IBCHNG(10, 1)     ! returns 8 = 1000

See Also