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

Content added Content deleted
m (→‎Initial C code specimen requires a long int algorithm: first left bit set, and the first right bit set?)
Line 1: Line 1:
== More Clarification "set bit" ==

The example gives <pre>INT: find first & last set bit |LWB|UPB|Bits
0| 33| 32|0</pre>
How are there any set bits in an unsigned integer? --[[User:Dgamey|Dgamey]] 03:43, 8 December 2011 (UTC)

===Clarification===
===Clarification===
The task is unclear in what number should be computed. It mentions "first" and "last" set bits, but with bits written in most-significant to least-significant order, or the other way around? (i.e. which of "upb" and "lwb" should compute the least significant set bit? and which computes the most significant set bit?) For a 32-bit integer should the least significant bit be numbered 0, 1, 31, or 32? Also, what values should be returned if there are no set bits? And for negative integers, should the most significant set bit be the sign bit?
The task is unclear in what number should be computed. It mentions "first" and "last" set bits, but with bits written in most-significant to least-significant order, or the other way around? (i.e. which of "upb" and "lwb" should compute the least significant set bit? and which computes the most significant set bit?) For a 32-bit integer should the least significant bit be numbered 0, 1, 31, or 32? Also, what values should be returned if there are no set bits? And for negative integers, should the most significant set bit be the sign bit?