Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: int2bin

by MrNobo1024 (Hermit)
on Aug 11, 2002 at 17:40 UTC ( #189314=note: print w/replies, xml ) Need Help??


in reply to int2bin

You're doing far more work than you have to. printf has a %b format for printing numbers out in binary:
#!/usr/bin/perl -w print "Input number: "; my $num = <>; my $len = (length(sprintf("%b", $num)) + 7) & ~7; printf "\nBinary: %0${len}b\n", $num;

--MrNobo1024
s]]HrLfbfe|EbBibmv]e|s}w}ciZx^RYhL}e^print

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://189314]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2018-01-16 15:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (182 votes). Check out past polls.

    Notices?