in reply to Re: Decimal to Binary using Bitwise and operator
in thread Decimal to Binary using Bitwise and operator
# Program to convert Decimal no. 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, "\n"; print "The decimal number AND 64 gives us: ", $decimal & 64, "\n"; print "The decimal number AND 32 gives us: ", $decimal & 32, "\n"; print "The decimal number AND 16 gives us: ", $decimal & 16, "\n"; print "The decimal number AND 8 gives us: ", $decimal & 8, "\n"; print "The decimal number AND 4 gives us: ", $decimal & 4, "\n"; print "The decimal number AND 2 gives us: ", $decimal & 2, "\n\n"; print "The decimal number AND 1 gives us: ", $decimal & 1, "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Decimal to Binary using Bitwise and operator
by RMGir (Prior) on Jul 16, 2009 at 11:49 UTC | |
by AchyuthaRao (Initiate) on Jul 17, 2009 at 09:03 UTC | |
by Anonymous Monk on Nov 12, 2009 at 23:24 UTC | |
by jhumphreys (Novice) on Oct 04, 2012 at 02:26 UTC | |
by RMGir (Prior) on Oct 04, 2012 at 11:38 UTC | |
by jhumphreys (Novice) on Oct 04, 2012 at 17:32 UTC | |
by Anonymous Monk on Sep 02, 2017 at 11:00 UTC | |
by roboticus (Chancellor) on Sep 02, 2017 at 17:25 UTC |