Jump to content

Find first and last set bit of a long integer: Difference between revisions

Line 1,262:
=== Library ===
{{works with|Java|1.5+}}
 
Notes:
* least significant bit is bit 0 (such that bit ''i'' always has value 2<sup>i</sup>, and the result is independent of integer type width)
* when the integer 0 is given, mssb() and lssb() both return no bits set; mssb_idx() and lssb_idx() will return -1 and the integer type width, respectively
<syntaxhighlight lang="java">public class FirstAndLastBits {
 
915

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.