in reply to Re^3: Decimal to Binary using Bitwise and operator
in thread Decimal to Binary using Bitwise and operator
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Decimal to Binary using Bitwise and operator
by roboticus (Chancellor) on Sep 02, 2017 at 17:25 UTC |