LEADZ — Number of leading zero bits of an integer

LEADZ()

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

Parameters

I – Shall be of type INTEGER.

Returns

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).

Standard:

Fortran 2008 and later

Class:

Elemental function

Syntax:

RESULT = LEADZ(I)

Example:

PROGRAM test_leadz
  WRITE (*,*) BIT_SIZE(1)  ! prints 32
  WRITE (*,*) LEADZ(1)     ! prints 31
END PROGRAM
See also:

BIT_SIZE, TRAILZ, POPCNT, POPPAR