Is there an easy way to know what is the highest bit set (assume positive integers) in an int in python? I can write something that can try comparing with an int with a single bit set and left-shift it until I go over the int I am trying to analyze:
target=some-integer
bit_set=0
temp=1
while temp < target:
bit_set+=1
temp << 1
printf(f"The highest bit set is {bit_set-1}")
But I wonder if there's a straight method available in the int
for that (and I can't seem to find one, at least).