Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public
Document Table of Contents

MERGE_BITS

Elemental Intrinsic Function (Generic): Merges bits by using a mask.

result = MERGE_BITS (i,j,mask)

i

(Input) Must be of type integer, or a binary, octal, or hexadecimal literal constant.

j

(Input) Must be of type integer, or a binary, octal, or hexadecimal literal constant.

mask

(Input) Must be of type integer, or a binary, octal, or hexadecimal literal constant.

If both i and j are of type integer they must have the same kind type parameter. They cannot both be binary, octal, or hexadecimal literal constants.

If mask is of type integer, it must have the same kind type parameter as each other argument of type integer.

Results

The result type and kind are the same as i if i is of type integer; otherwise, the result type and kind are the same as j.

If any argument is a binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic function INT to the type and kind parameter of the result. The result has the value of IOR (IAND (i, mask), IAND (j, NOT (mask))).

Example

MERGE_BITS (13, 18, 22) has the value 4.