[ HPF Home | Versions | Compilers | Projects | Publications | Applications | Benchmarks | Events | Contact ]



Next:
MAXVAL_PREFIX(ARRAYDIM, MASK, Up: Specifications of Library Previous: IPARITY_SUFFIX(ARRAYDIM, MASK,

LEADZ(I)

Description. Return the number of leading zeros in an integer.
Class. Elemental function.
Argument. I must be of type integer.
Result Type and Type Parameter. Same as I.
Result Value. The result is a count of the number of leading 0-bits in the integer I. The model for the interpretation of an integer as a sequence of bits is in Section 13.5.7 of the Fortran 90 Standard. LEADZ(0) is BIT_SIZE(I). For nonzero I, if the leftmost one bit of I occurs in position (where the rightmost bit is bit 0) then LEADZ(I) is BIT_SIZE(I) - k.
Examples. LEADZ(3) has the value BIT_SIZE(3) - 2. For scalar I, LEADZ(I) .EQ. MINVAL( (/ (J, J=0, BIT_SIZE(I) ) /), MASK=M ) where M =(/ (BTEST(I,J), J=BIT_SIZE(I)-1, 0, -1), .TRUE. /). A given integer I may produce different results from LEADZ(I), depending on the number of bits in the representation of the integer (BIT_SIZE(I)). That is because LEADZ counts bits from the most significant bit. Compare with ILEN.



©2000-2006 Rice University [ Contact Us | HiPerSoft | Computer Science ]

paula@erc.msstate.edu
Thu Dec 8 16:17:11 CST 1994