I occasionally want to publish perl modules that require 64-bit integers and "pack 'Q'" support. The modules can be expanded to work on old and 32-bit perls by using BigInt, but I don't want to encumber the main users of the module with that performance hit for such rarely encountered environments. I'm looking for a generic toolkit of functions to solve this, and if it doesn't exist, I'm looking for a good CPAN name to publish mine.

For example, here is the shim I made to support "pack 'Q'" for 32-bit perl and the test I use to usually avoid needing it.

I also want to be able to declare 64-bit constants, for which I created this: (not yet published)

sub _int64_native { $_[0] =~ /^(-?)0x(.*)/? hex($2)*($1? -1 : 1) : 0+$_[0] } sub _int64_bigint { Math::BigInt->new($_[0]) } # Can scalars hold 64-bit ints natively? if ((0x7FFFFFFE << 31) > 0 && (0x7FFFFFFE << 63) == 0) { *int64= \&_int64_native; } else { *int64= \&_int64_bigint; }

Which I can use like this:

int64('-0x10000000000');

Before I go too far here, is there a CPAN module I'm overlooking?

If not, I'd like to make one. What should I name it?


In reply to Supporting 64-bit ints on 32-bit perl by NERDVANA

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.