Home

Next: , Previous: , Up: Intrinsic Procedures   [Contents][Index]


9.51 BTEST — Bit test function

Description:

BTEST(I,POS) returns logical .TRUE. if the bit at POS in I is set. The counting of the bits starts at 0.

Standard:

Fortran 90 and later, has overloads that are GNU extensions

Class:

Elemental function

Syntax:

RESULT = BTEST(I, POS)

Arguments:
IThe type shall be INTEGER.
POSThe type shall be INTEGER.
Return value:

The return value is of type LOGICAL

Example:
program test_btest
    integer :: i = 32768 + 1024 + 64
    integer :: pos
    logical :: bool
    do pos=0,16
        bool = btest(i, pos) 
        print *, pos, bool
    end do
end program test_btest
Specific names:
NameArgumentReturn typeStandard
BTEST(I,POS)INTEGER I,POSLOGICALFortran 95 and later
BBTEST(I,POS)INTEGER(1) I,POSLOGICAL(1)GNU extension
BITEST(I,POS)INTEGER(2) I,POSLOGICAL(2)GNU extension
BJTEST(I,POS)INTEGER(4) I,POSLOGICAL(4)GNU extension
BKTEST(I,POS)INTEGER(8) I,POSLOGICAL(8)GNU extension