Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: decimal to binary

by GrandFather (Saint)
on Jan 09, 2012 at 06:57 UTC ( [id://946952]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    use warnings;
    ...
    $bits[1] = ($dec & 2) <=> 0;
    $bits[0] = ($dec & 1) <=> 0;
    printf "The entered decimal number in binary is : %s\n", join '', reve
    +rse @bits;
    
  2. or download this
    ...
    my @bits;
    
    $bits[$_] = ($dec & 2 ** $_) <=> 0 for 0 .. 7;
    printf "The entered decimal number in binary is : %s\n", join '', reve
    +rse @bits;
    
  3. or download this
    ...
    my @bits;
    ...
    }
    
    printf "The entered decimal number in binary is : %s\n", join '', reve
    +rse @bits;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://946952]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-25 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found