MERGE_BITS(I, J, MASK) (Fortran 2008)

Purpose

Merges bits under mask.

Class

Elemental function

Argument type and attributes

I
An INTENT(IN) INTEGER or boz-literal CONSTANT
J
An INTENT(IN) INTEGER or boz-literal CONSTANT.

If both I and J are of type INTEGER they must have the same kind type parameter. I and J must not both be boz-literal CONSTANT.

MASK
An argument of type integer or a boz-literal constant. If MASK is of type integer, its kind must be the same as each other argument of type integer.

Result type and attributes

Same as I if I is of type integer. Otherwise, same as J.

Result value

If any argument is a boz-literal constant, it is first converted to the type and kind type parameter of the result. The result has the value of IOR (IAND (I, MASK),IAND (J, NOT (MASK))).

Example

MERGE_BITS (5, 10, 41) has the result 3.