locate first nonzero bit from a location in a specified direction
either higher or lower, indicating the direction of the search
bit offset to start search at
The FirstNonzeroBit command locates the first nonzero bit in a number in a specified direction from a specified location.
By default, the command searches in the lower direction starting at the most significant bit in the number. In this way, calling it with no additional arguments gives an identical result as the ilog2 command.
Note that for negative numbers, the most significant bit does not exist, so infinity is returned.
If dir is specified as lower, then the number will be searched in the direction of the most significant bit to the least significant bit.
If posn is not specified, it defaults to the most significant bit in the number.
If there are no bits lower than posn, -1 is returned.
If dir is specified as higher, then the number will be searched in the direction of the least significant bit to the most significant bit.
If posn is not specified, it defaults to 0.
If there are no bits higher than posn, infinity is returned.
Download Help Document
What kind of issue would you like to report? (Optional)