Manual Reference Pages  - ibclr (3fortran)

NAME

IBCLR(3) - [BIT:SET] Clear a bit

SYNOPSIS

result = ibclr(i, pos)

         elemental integer(kind=KIND) function ibclr(i,pos)

integer(kind=KIND),intent(in) :: i integer(kind=**),intent(in) :: pos

CHARACTERISTICS

o I shall be type integer.
o POS shall be type integer.
o The return value is of the same kind as I.
o a kind designated as ** may be any supported kind for the type

DESCRIPTION

IBCLR(3) returns the value of I with the bit at position POS set to zero.

OPTIONS

o I : The initial value to be modified
o POS : The position of the bit to change in the input value. A value of zero refers to the right-most bit. The value of POS must be nonnegative and less than (BIT_SIZE(I)).

RESULT

The returned value has the same bit sequence as I except the designated bit is unconditionally set to 0

EXAMPLES

Sample program:

    program demo_ibclr
    use,intrinsic :: iso_fortran_env,  only : int8, int16, int32, int64
    implicit none
    integer(kind=int16) :: i
      ! basic usage
       print *,ibclr (16, 1), ’ ==> ibclr(16,1) has the value 15’

! it is easier to see using binary representation i=int(b’0000000000111111’,kind=int16) write(*,’(b16.16,1x,i0)’) ibclr(i,3), ibclr(i,3)

! elemental print *,’an array of initial values may be given as well’ print *,ibclr(i=[7,4096,9], pos=2) print * print *,’a list of positions results in multiple returned values’ print *,’not multiple bits set in one value, as the routine is ’ print *,’a scalar function; calling it elementally essentially ’ print *,’calls it multiple times. ’ write(*,’(b16.16)’) ibclr(i=-1_int16, pos=[1,2,3,4])

! both may be arrays if of the same size

end program demo_ibclr

Results:

     >           16  ==> ibclr(16,1) has the value 15
     > 0000000000110111 55
     >  an array of initial values may be given as well
     >            3        4096           9
     >
     >  a list of positions results in multiple returned values
     >  not multiple bits set in one value, as the routine is
     >  a scalar function; calling it elementally essentially
     >  calls it multiple times.
     > 1111111111111101
     > 1111111111111011
     > 1111111111110111
     > 1111111111101111

STANDARD

Fortran 95

SEE ALSO

BTEST(3), IAND(3), IBITS(3), IBSET(3), IEOR(3), IOR(3), MVBITS(3), NOT(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 ibclr (3fortran) April 28, 2024
Generated by manServer 1.08 from 34bb79db-c06e-4571-ae30-e48fa6b139a4 using man macros.