I asked a question about manipulating 64-bit values. Elian and samtregar were kind enough to offer their responses. samtregar suggested using 5.8.0RC1. Because I don't want to force that version on users, I took Elian's suggestion of using 'use integer'.

That works pretty well, with a couple of exceptions. For one, hex() still uses floats, but that's pretty acceptable and easy to work around.. However, the kicker is that 'use integer' treats all values as signed. That causes problems when doing comparisons. For instance, 0x80000000000000000 will be less than 0x70000000000000000, because the highest bit is set.

I really need to convince perl to treat these as unsigned quantities. For now, I'm doing this by creating an "Address" class, and using operator overloading for "<=>" (and simple overloads for other mathematical operators). However, this is making the code much slower. (I'm dealing with these addresses a lot)

Is there any way I can convince perl to manipulate the values as (essentially) uint64_t's?


In reply to 'use integer;', or Manipulating 64-bit values, revisited by rjbell4

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.