Clicky

Fortran Wiki
leadz

Description

leadz returns the number of leading zero bits of an integer.

Standard

Fortran 2008 and later

Class

Elemental function

Syntax

result = leadz(i)

Arguments

  • i - Shall be of type integer.

Return value

The type of the return value is the default integer. If all the bits of i are zero, the result value is bit_size(i).

Example

program test_leadz
  write (*,*) leadz(1)  ! prints 8 if bitsize(i) has the value 32
end program

See also

bit_size, popcnt, poppar, trailz

category: intrinsics