sub most_significant_ix { my $n = shift; return if $_[0] == 0; return int(log($_[0])/log(2)); }