Intel® Fortran Compiler 17.0 Developer Guide and Reference
Elemental Intrinsic Function (Generic): Tests a bit of an integer argument.
result = BTEST (i,pos)
i |
(Input) Must be of type integer or of type logical (which is treated as an integer). |
pos |
(Input) Must be of type integer. It must not be negative and it must be less than BIT_SIZE(i). The rightmost (least significant) bit of i is in position 0. |
The result type is default logical.
The result is true if bit pos of i has the value 1. The result is false if pos has the value zero. For more information, see Bit Functions.
For information on the model for the interpretation of an integer value as a sequence of bits, see Model for Bit Data.
The setting of compiler options specifying integer size can affect this function.
Specific Name |
Argument Type |
Result Type |
---|---|---|
BBTEST |
INTEGER(1) |
LOGICAL(1) |
BITEST1 |
INTEGER(2) |
LOGICAL(2) |
BTEST 2 |
INTEGER(4) |
LOGICAL(4) |
BKTEST |
INTEGER(8) |
LOGICAL(8) |
1Or HTEST 2Or BJTEST |
BTEST (9, 3) has the value true.
If A has the value
[ 1 2 ] [ 3 4 ],
the value of BTEST (A, 2) is
[ false false ] [ false true ]
and the value of BTEST (2, A) is
[ true false ] [ false false ].
The following shows more examples:
Function reference |
Value of i |
Result |
---|---|---|
BTEST ( i,2) |
00011100 01111000 |
.FALSE. |
BTEST ( i,3) |
00011100 01111000 |
.TRUE. |
The following shows another example:
INTEGER(1) i(2)
LOGICAL result(2)
i(1) = 2#10101010
i(2) = 2#01010101
result = BTEST(i, (/3,2/)) ! returns (.TRUE.,.TRUE.)
write(*,*) result