M503: Locate the One-Bits of a Word or an Array

Author(s): M. Metcalf, R. Matthews Library: KERNLIB
Submitter: Submitted: 01.02.1982
Language: Fortran or Assembler Revised: 20.06.1985

UBITS locates and counts the 1-bits in the right-most NBITS bits in a word or full-word array, returning their positions. Bit numbering is right to left, bit number 1 being the least significant bit in the first full word, bit number NBPW+1 being the least significant bit in the second full word, where NBPW is the number of bits per machine word.

Structure:

SUBROUTINE subprogram
User Entry Names: UBITS
External References: UPKBYT (Fortran version only)

Usage:

    CALL UBITS(IWORDS,NBITS,IXV,NX)
IWORDS
Word or full-word array to be analysed.
NBITS
Bits 1 to NBITS of array IWORDS are inspected.
IXV
Bit positions of the 1-bits in IWORD are placed into IXV(1) through IXV(NX) in increasing order. IXV must be dimensioned to NBITS at least.
NX
Number of 1-bits found.

Examples:

     DIMENSION IXV(9)
     IWORD=1676
C    1676 in base 2 is 11010001100
     CALL UBITS(IWORD,9,IXV,NX)
sets
   NX = 3, IXV(1) = 3, IXV(2) = 4, IXV(3) = 8.
tex2html_wrap_inline66

Michel Goossens Wed Jun 5 07:47:17 METDST 1996