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

Re: binary conversion

by TJPride (Pilgrim)
on Dec 12, 2011 at 21:59 UTC ( [id://943194]=note: print w/replies, xml ) Need Help??


in reply to binary conversion

Probably not what they want, but the best I could come up with on short notice without cheating and just telling Perl to convert directly.

use strict; use warnings; my $nd = 186; my $nb = ''; for (reverse (0..7)) { if ($nd >= 2**$_) { $nb .= '1'; $nd -= 2**$_; } else { $nb .= '0'; } } print $nb;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-03-28 14:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found