Lahey/Fujitsu Fortran

IBSET Function

Description

The IBSET function sets one or more bits in an INTEGER argument to one.

Syntax

IBSET (i, pos)

Arguments

i is an INTENT(IN) scalar or array of type INTEGER.

pos is an INTENT(IN) scalar or array of type INTEGER. The value of pos must be within the range zero to (BIT_SIZE(i)-1).

If i and pos are both arrays, they must have the same shape.

Result

The result is of type INTEGER and of the same kind as i. Its value is i with the bit at position pos is set to one.

If i is an array and pos is scalar, the result is an array with the same shape as i. Each element of the resulting array has the bit at position pos set to one.

If i is scalar and pos is an array, the result is an array with the same shape as pos. Each element of the resulting array contains the value of i with the bit indicated by the corresponding element of pos set to one.

If i and pos are both arrays, the result is an array with the same shape as i. Each element of the resulting array contains the value from the corresponding element of i with the bit indicated by the corresponding element of pos set to one.

Example

integer :: i=0,p=3,ia(2)=(/0,0/),pa(2)=(/1,2/) write(*,"(b34)") i ! writes 0 write(*,"(b34)") ibset(i,p) ! writes 1000 write(*,"(2b34)") ibset(i,pa) ! writes 10 100 write(*,"(2b34)") ia ! writes 0 0 write(*,"(2b34)") ibset(ia,p) ! writes 1000 1000 write(*,"(2b34)") ibset(ia,pa) ! writes 10 100

See Also

BIT_SIZE Function