sub most_significant_ix { my $n = shift; return undef if $n == 0; my $bits = 64; while (--$bits >= 0) { return $bits if (2**$bits) & $n; } }