I got some numbers and I need to get how much they should be shifted for their lower bit to be at position 0.
ex:
0x40000000 => 30 because 0x40000000 >> 30 = 1
768 = 512+256 => 8
This works
if (Math.log2(x) == 31)
return 31;
if (Math.log2(x) > 31)
x = x & 0x7FFFFFFF;
return Math.log2(x & -x)
Is there any more efficient or elegant way (builtin ?) to do this in javascript ?