Clicky

Fortran Wiki
trailz

Description

trailz returns the number of trailing zero bits of an integer.

Standard

Fortran 2008 and later

Class

Elemental function

Syntax

result = trailz(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_trailz
  write (*,*) trailz(8)  ! prints 3
end program

See also

bit_size, popcnt, poppar, leadz

category: intrinsics