code: static short bin2int(            /* output: decimal value of bit pattern */
  	 int no_of_bits,        /* input : number of bits to read */
  	 short []bitstream, int bitstreams       /* input : array containing bits */
  	)
  	{
  	   short   value, i;
  	   short bit;
  
  	   value = 0;
  	   for (i = 0; i < no_of_bits; i++)
  	   {
  	     value <<= 1;
  	     bit = bitstream[bitstreams++];
  	     if (bit == LD8KConstants.BIT_1)  value += 1;
  	   }
  	   return(value);
  	}
docs: /*----------------------------------------------------------------------------
  bin2int - read specified bits from bit array  and convert to integer value
  ----------------------------------------------------------------------------