I don't think a 32 bit perl has a direct equivalent of 64 bit integers. That probably means you can do 3 things:

1. Use a 32 bit int (i.e. T_IV or T_UV) which has the advantage that any numbers in the 32 bit range can be accurately be represented, but higher numbers cannot be represented at all.

2. Use a floating point number (i.e. T_NV, which is an 8-bitbyte double on my system) which is able to represent the whole range, but not 100% accurately.

3. Create your own type conversion from/to a perl object (i.e. an XS pointer to a long long, in which case you need to provide some mechanism for read/write access, or maybe you can convert from/to Math::BigInt). Probably the most hassle, but you can guarantee precision and range.

Update: I just thought of another way: you can convert from/to a string representation of the number. Should be easy to do, but the perl side of things has to be careful not to accidentally convert it back to a number (float or int). That means you won't be able to do normal arithmatics with it (you'll have to use Math::BigInt or something similar).


In reply to Re: Supporting long long types in XS by Joost
in thread Supporting long long types in XS by chrisdolan

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.