$ perl -le'my $buf = "\x47\x69\x01"; print unpack "B*", substr( $buf, -2 ) & "\x1f\xff"' 0000100100000001