btest

Date:

10-12-2011

NAME

BTEST, BITEST, BJTEST, BKTEST - Test a bit of an integer value

SYNOPSIS

BTEST ([I=]i, [POS=]pos)
BITEST ([I=]i, [POS=]pos)
BJTEST ([I=]i, [POS=]pos)
BKTEST ([I=]i, [POS=]pos)

IMPLEMENTATION

Cray Linux Environment (CLE)

STANDARDS

Fortran

Fortran extensions: BITEST, BJTEST, BKTEST

DESCRIPTION

The BTEST, BITEST, BJTEST, and BKTEST intrinsic functions test a bit of an integer value. They accept the following arguments:

i

Must be of type integer. For BITEST, it must be an integer (KIND=2) value. For BJTEST, it must be an integer (KIND=4) value. For BKTEST, it must be an integer (KIND=8) value.

pos

Must be of type integer. For BITEST, it must be an integer (KIND=2) value. For BJTEST, it must be an integer (KIND=4) value. For BKTEST, it must be an integer (KIND=8) value. It must be nonnegative and be less than BIT_SIZE(i).

BTEST, BITEST, BJTEST, and BKTEST are elemental functions. The names of these intrinsics cannot be passed as arguments.

RETURN VALUES

BTEST returns type default logical. BITEST returns type logical (KIND=2). BJTEST returns type logical (KIND=4). BKTEST returns type logical (KIND=8).

The result has the value TRUE if bit pos of i has the value 1. It has the value FALSE if bit pos of i has the value 0. The bit model defines the interpretation of an integer value as a sequence of bits. This model is described in the models(3i) man page.

EXAMPLES

Example 1: BTEST(8,3) yields TRUE.

Example 2: BTEST(8_SHORT,3) yields TRUE.

Example 3: Assume that A has the following value:

| 1 2 |
| 3 4 |

BTEST(A,2) yields:

| false false |
| false  true |

BTEST(2,A) yields:

| true   false |
| false  false |

SEE ALSO

models(3i)