more useful options | |
PerlMonks |
Best way to represent somewhat large values in a moduleby sgifford (Prior) |
on Jun 19, 2004 at 06:07 UTC ( [id://368123]=perlquestion: print w/replies, xml ) | Need Help?? |
sgifford has asked for the wisdom of the Perl Monks concerning the following question: 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!
Back to
Seekers of Perl Wisdom
|
|