I'm working on some Perl modules to handle RFID tags. The tag IDs can be up to 96 bits. I'm not sure what the best way to accept these IDs as parameters, and return them, and wanted to ask for some ideas.

Right now, I'm just accepting and returning hex strings, and treating the tag IDs as somewhat opaque strings. But it's possible somebody will want to do bitwise operations on the tags (e.g. to & it with some mask), in which case they have to convert them from hex into something they can compute with. And my module is spending a lot of time converting to and from hex.

Math::BigInt seems like overkill for this, since for the most part representing the tags as strings will work fine. And using pack and unpack makes them unprintable, which is annoying.

So my question is, if you were using a module that dealt with a 96-bit ID number in various ways, what would you find the most convenient representation to work with? Or, if you were designing a module that had to work with 96-bit ID numbes, what factors would you take into consideration when thinking about the representation?

Any thoughts are appreciated!


In reply to Best way to represent somewhat large values in a module by sgifford

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.