Optimized findMSB and findLSB