programming-examples/perl/Basics/Bitwise operator.pl

18 lines
367 B
Perl
Raw Normal View History

2019-11-18 14:44:36 +01:00
#!/usr/bin/perl
use warnings;
use strict;
my $a = 3;
my $b = 6;
my $r;
printf "$a = %03b \n", $a;
printf "$b = %03b \n", $b;
$r = $a & $b; printf "$a & $b = %03b = %d\n", $r, $r;
$r = $a | $b; printf "$a | $b = %03b = %d\n", $r, $r;
$r = $a ^ $b; printf "$a ^ $b = %03b = %d\n", $r, $r;
$r = ~$a; printf "~$a = %03b = %d\n", $r, $r;