Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2016-06-26 09:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (328 votes). Check out past polls.