Anonymous user
Find first and last set bit of a long integer: Difference between revisions
Find first and last set bit of a long integer (view source)
Revision as of 16:08, 5 April 2019
, 5 years agoRefactor Ruby loops by Integer#times
m (Refactor Ruby by #bit_length) |
m (Refactor Ruby loops by Integer#times) |
||
Line 1,309:
end
6.times do |i|
x = 42 ** i
puts "%10d MSB: %2d LSB: %2d" % [x, msb(x), lsb(x)]
end
6.times do |i|
x = 1302 ** i
puts "%20d MSB: %2d LSB: %2d" % [x, msb(x), lsb(x)]
|