MERGE_BITS (The GNU Fortran Compiler)

### 8.204 `MERGE_BITS` — Merge of bits under mask ¶

Synopsis:

  `RESULT = MERGE_BITS(I, J, MASK)`

Description:

  `MERGE_BITS(I, J, MASK)` merges the bits of I and J as determined by the mask. The i-th bit of the result is equal to the i-th bit of I if the i-th bit of MASK is 1; it is equal to the i-th bit of J otherwise.

Class:

  Elemental function

Arguments:

  I | Shall be of type `INTEGER`, `UNSIGNED` or a boz-literal-constant. I and J shall not both be boz-literal-constants.
  J | The type shall be the same type as I with the same kind type parameter or a boz-literal-constant.
  MASK | Shall be of the same type as I, J or a boz-literal-constant.

Return value:

  The result is of the same type and kind as I.

Standard:

  Fortran 2008 and later, extension for `UNSIGNED` (see Unsigned integers)