I wonder what you are really trying to do, once you get the answer to this question. Where is your "huge decimal number" really coming from?

If you are just playing with powers 1024, it might be good enough to know that the binary representation for 1024 is a "1" followed by 10 zeros. That is:

$binary_string = "1" . "0" x 10; print "$binary_string\n"
For each power of 1024, just add ten more zeros:
$power = 4; $binary_string = "1" . "0" x (10 * $power); # parens required print "$binary_string\n"
But I assume you are really trying to do something more complicated than that. For example, if you are trying to read a string of decimal digits of arbitrary length, and convert that to binary, I'm not sure anyone has posted a good solution for that yet. (I don't have a good solution for that, but I'm sure one can be found...)

In reply to Re: How turn a huge decimal number to binary by graff
in thread How turn a huge decimal number to binary by xiaoyafeng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.