print "Input a decimal number lesser than 256: ", "\n"; my $decimal; $decimal = <STDIN>; print "The decimal number AND 128 gives us: ", ($decimal & 128)>1, "\n +"; print "The decimal number AND 64 gives us: ", ($decimal & 64)>1, "\n"; print "The decimal number AND 32 gives us: ", ($decimal & 32)>1, "\n"; print "The decimal number AND 16 gives us: ", ($decimal & 16)>1, "\n"; print "The decimal number AND 8 gives us: ", ($decimal & 8)>1, "\n"; print "The decimal number AND 4 gives us: ", ($decimal & 4)>1, "\n"; print "The decimal number AND 2 gives us: ", ($decimal & 2)>1, "\n\n"; print "The decimal number AND 1 gives us: ", $decimal & 1, "\n";
2017-09-02 Athanasius added code tags
In reply to Re^4: Decimal to Binary using Bitwise and operator
by Anonymous Monk
in thread Decimal to Binary using Bitwise and operator
by AchyuthaRao
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |