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

Line 59:
: For the first/last nomenclature, an integer type has well defined least/most signicant bit concept, while first/last/left/right all depends on endianness. If the bits are transmitted on a wire, we also need to know the bit ordering in a byte, so these are hazy at best. The 32-bit number 257 can be stored in memory as either "01 01 00 00" or "00 00 01 01", so what's the "last" set bit? Or the "left most" one? Are we going to consider 32 bit as smallest unit, or 8 bit? Unless you have a spec about using these bits, lsb/msb is a better way to refer to them.
: As to the hex vs binary output, I personally find reading 8 hex digit is less stressful than reading 32 1s and 0s. I did provide the positions of the related bits, though. --[[User:Ledrug|Ledrug]] 04:22, 8 December 2011 (UTC)
 
C has given us << ''left'' shift and >> ''right'' shift operators for '''int''', '''long int''', and '''long long int'''. Clearly C knows the difference between left and right. That could be a good starting point. [[User:NevilleDNZ|NevilleDNZ]] 04:31, 8 December 2011 (UTC)