MERGE_BITS intrinsic function
Standard: F77 F90 F95 F2003 F2008
  Example Program
<Syntax>
MERGE_BITS ( I, J, MASK )

I : BOZ literal constant or Integer;
J : BOZ literal constant or Integer;
MASK : BOZ literal constant or Integer;

Result : Integer, same kind as I or J.

Note: At least one of I and J must be of type Integer. If both I and J are of type Integer, they must be the same kind.
<Semantics>

Returns the bit-merge of I, J, and MASK; this means for each bit of MASK that is 1, the corresponding bit of the result is taken from that bit of I, and otherwise is taken from J.

This is equivalent to IOR(IAND(I,MASK),IAND(J,NOT(MASK))).

Like many intrinsic functions, this is elemental; if all arguments are scalar the result is scalar, if any argument is an array the other arguments must either be scalars or arrays with the same shape, and the result is an array of that shape with the operation being applied elementwise.

If any argument is a BOZ literal constant, it is converted to the result type as if by the INT intrinsic function.

<Related>
IAND intrinsic function, IOR intrinsic function, MERGE intrinsic function, NOT intrinsic function.