aboutsummaryrefslogtreecommitdiff
path: root/challenge-120/belmark-caday/perl/ch-1.pl
blob: 385f6d4a1cca10474607c52b9b39d2a4ffb345a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl

print swapOddEvenInt($ARGV[0]);

sub swapOddEvenInt {
    my $num = shift;

    my $even = $num & 0xAAAAAAAA;
    my $odd = $num & 0x55555555;

    $even >>= 1;
    $odd <<= 1;

    return $even | $odd;
}