2 raised to the 64th power is only 18 446 744 073 709 551 616, or around 18 and a half quintillion. Or about 16 exabytes. Which is fantistically huge, or woefully inadequate, depending on what your needs are.

Math::BigInt lets you define numbers as  my $num = Math::BigInt->new( '18 446 744 073 709 551 617' ) which is as about as clean as it gets.

Internally, the package uses base 10 arithmetic, not base 2 (or 16), which is why I suspect you can't enter numbers in hex format. I suppose no-one has got around to patching the package to do it. Converting between base 10 and base 16 is algorithmically fairly trivial but computationally quite expensive, as you have to perform repeated divisions. (Update: to be precise, converting from hex to dec is easy. I was thinking about converting from decimal to hex... unless there's something I've missed, you can't do it with lookup tables).

Your easiest bet would be to write a program that takes an arbirtarily long hex string and converts it to base 10, and use that constant in your program. For extra credit, you could patch the Math::BigInt package to allow the 0x prefix to signify a hex representation, and have the package decode it.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

In reply to Re: Big Numbers by grinder
in thread Big Numbers by RollyGuy

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.