Apply remaining fixes from #8732. Also adds msb (most significant bit) function to multiprecision. Fixes #8732.