|
|
| go ahead... be a heretic | |
| PerlMonks |
Re: Bitwise AND with large numbersby Eliya (Priest) |
| on Apr 12, 2012 at 17:50 UTC ( #964799=note: print w/ replies, xml ) | Need Help?? |
|
You can do bitwise AND with strings, too (in which case there's no size limitation). So, convert your hex string and your number to binary strings using pack (e.g. pack "H*", $hexstring for the hex string), pad the shorter one to the length of the longer one (with \0 or \xff, depending on the desired semantics), AND (&) both strings, and convert the result back to whatever you like (e.g. hex string). The details somewhat depend on what exactly you need, so if you provide sample inputs and desired result, someone will surely come up with actual code... Otherwise, if you want to stick with Math::Big*, there is from_hex().
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||