in reply to Bitwise AND with large numbers
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().
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bitwise AND with large numbers
by mdej (Initiate) on Apr 16, 2012 at 16:56 UTC | |
by Eliya (Vicar) on Apr 16, 2012 at 17:12 UTC | |
by mdej (Initiate) on Apr 20, 2012 at 08:20 UTC |