Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^5: Decimal to Binary using Bitwise and operator

by Anonymous Monk
on Nov 12, 2009 at 23:24 UTC ( #806826=note: print w/replies, xml ) Need Help??


in reply to Re^4: Decimal to Binary using Bitwise and operator
in thread Decimal to Binary using Bitwise and operator

#!/usr/bin/perl -w # decbi.pl # author: Jeff S # date: 11/12/09 # convert a decimal less than 256 to binary print "Please enter the value(less than 256) you wish to convert into a binary number: \n"; $bin = <STDIN>; chomp ($bin); print "The binary value of $bin is: ", "\n"; #use the bitwise & operator to get the binary value: print ((128&$bin) /128); print ((64&$bin) /64); print ((32&$bin) /32); print ((16&$bin) /16); print ((8&$bin) /8); print ((4&$bin) /4); print ((2&$bin) /2); print ((1&$bin) /1);
  • Comment on Re^5: Decimal to Binary using Bitwise and operator

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://806826]
help
Chatterbox?
[Corion]: Whooops - I misread and miuxed Ubuntu and the ActiveState Perl question. Sorry!
[Corion]: Discipulus: Hurr - I'd use the command line, as always
[Discipulus]: my last linux experience was with redhad 5.6 and occasionally with partedmagic.. i need to relearn everything.. :=(

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2016-12-07 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (125 votes). Check out past polls.