Manual Reference Pages  - maskl (3fortran)

NAME

MASKL(3) - [BIT:SET] Generates a left justified mask

SYNOPSIS

result = maskl( i [,kind] )

         elemental integer(kind=KIND) function maskl(i,KIND)

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

CHARACTERISTICS

o a kind designated as ** may be any supported kind for the type
o I is an integer
o KIND Shall be a scalar constant expression of type integer whose value is a supported integer kind.
o The result is an integer of the same kind as I unless KIND is present, which is then used to specify the kind of the result.

DESCRIPTION

MASKL(3) has its leftmost I bits set to 1, and the remaining bits set to
0.

OPTIONS

o I : the number of left-most bits to set in the integer result. It must be from 0 to the number of bits for the kind of the result. The default kind of the result is the same as I unless the result size is specified by KIND. That is, these Fortran statements must be [char46]true. :

       i >= 0 .and. i < bitsize(i) ! if KIND is not specified
       i >= 0 .and. i < bitsize(0_KIND) ! if KIND is specified

o KIND : designates the kind of the integer result.

RESULT

The leftmost I bits of the output integer are set to 1 and the other bits are set to 0.

EXAMPLES

Sample program:

    program demo_maskl
    implicit none
    integer :: i
      ! basics
       i=3
       write(*,’(i0,1x,b0)’) i, maskl(i)

! elemental write(*,’(*(i11,1x,b0.32,1x,/))’) maskl([(i,i,i=0,bit_size(0),4)]) end program demo_maskl

Results:

     > 3 11100000000000000000000000000000
     >           0 00000000000000000000000000000000
     >  -268435456 11110000000000000000000000000000
     >   -16777216 11111111000000000000000000000000
     >    -1048576 11111111111100000000000000000000
     >      -65536 11111111111111110000000000000000
     >       -4096 11111111111111111111000000000000
     >        -256 11111111111111111111111100000000
     >         -16 11111111111111111111111111110000
     >          -1 11111111111111111111111111111111

STANDARD

Fortran 2008

SEE ALSO

MASKR(3)

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


Nemo Release 3.1 maskl (3fortran) April 28, 2024
Generated by manServer 1.08 from 7d536049-3e14-4fb1-b039-9cbbe3f7a437 using man macros.