DEV Community

Discussion on: Perl flexibility for the win

Collapse
 
drhyde profile image
David Cantrell

FWIW, assuming an 8 bit input, my perl solution to the nibble-switcher would be

$n = (($n & 0b1111) << 4) + ($n >> 4)
Enter fullscreen mode Exit fullscreen mode