Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Bitwise-operations/Perl/bitwise-operations.pl
Normal file
15
Task/Bitwise-operations/Perl/bitwise-operations.pl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use integer;
|
||||
|
||||
sub bitwise :prototype($$) {
|
||||
($a, $b) = @_;
|
||||
print 'a and b: '. ($a & $b) ."\n";
|
||||
print 'a or b: '. ($a | $b) ."\n";
|
||||
print 'a xor b: '. ($a ^ $b) ."\n";
|
||||
print 'not a: '. (~$a) ."\n";
|
||||
print 'a >> b: ', $a >> $b, "\n"; # logical right shift
|
||||
|
||||
use integer; # "use integer" enables bitwise operations to return signed ints
|
||||
print "after use integer:\n";
|
||||
print 'a << b: ', $a << $b, "\n"; # left shift
|
||||
print 'a >> b: ', $a >> $b, "\n"; # arithmetic right shift
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue