Jump to content

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

m
Refactor 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|
for i in 0...6
x = 42 ** i
puts "%10d MSB: %2d LSB: %2d" % [x, msb(x), lsb(x)]
end
 
6.times do |i|
for i in 0...6
x = 1302 ** i
puts "%20d MSB: %2d LSB: %2d" % [x, msb(x), lsb(x)]
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.