Finding the Most Significant Set Bit of a Word in Constant Time

from blog Fred Akalin, | ↗ original
// Converts the given binary string (possibly with whitespace) to an integer. function b(s) { return parseInt(s.replace(/\s+/g, ''), 2); } // Converts the given integer to a binary string. function bs(x) { return x.toString(2); } 1. Overall method Finding the most significant set bit of a word (equivalently, finding the integer log base 2 of...