ILEN(I) (IBM extension)

Purpose

Returns one less than the length, in bits, of the twos complement 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

  • If I is negative, ILEN(I)=CEILING(LOG2(-I))
  • If I is nonnegative, ILEN(I)=CEILING(LOG2(I+1))

Examples

I=ILEN(4)  ! 3
J=ILEN(-4) ! 2