SEARCH FIRST BIT SET
Original Publication Date: 1989-Nov-01
Included in the Prior Art Database: 2005-Jan-29
The invention disclosed identifies a method to find the bit number of the most significant bit set in a word. It utilizes the fixed-to- float instruction found on many processors. To find the bit number of the most significant bit set in a 16-bit word, for example, the following steps are performed: 1. Assume the most significant bit (MSB) is numbered 0 and least significant bit (LSB) is numbered 15. Note: If the bits are numbered in the reverse order, see the alternate method below. 2. If the input value is positive (bit 0 is not set), then a. Convert input value to floating point number. b. Exclusive-OR resulting exponent with 1s (i.e., 0000 1111 for 16-bit word, 0001 1111 for 32-bit word, etc. c. Continue normal processing.