TRAILZ(I) (Fortran 2008)

Purpose

Returns the number of trailing zero bits in the binary representation of an integer.

Class

Elemental function

Argument type and attributes

I
An INTENT(IN) INTEGER

Result type and attributes

Same as I.

Result value

The result is the count of zero bits to the right of the rightmost one bit for I. If I has the value zero, the result is BIT_SIZE(I).

Examples

 I = TRAILZ(0_4)  ! I=32
 J = TRAILZ(4_4)  ! J=2
 K = TRAILZ(-1)   ! K=0
 M = TRAILZ(0_8)  ! M=64
 N = TRAILZ(1_8)  ! N=0

Related information