Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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


Comment on Re: int2bin
Download Code

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 imbibing at the Monastery: (12)
As of 2014-09-22 08:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (185 votes), past polls