in reply to Hex to decimal resulting in integer overflow
Your build of Perl cannot hold numbers that big (48 bits).
my $num = hex(substr(("0"x12).$hex, -12, 4)) * 2**32 + hex(substr(("0"x12).$hex, -8));
Update: Added mention on Math::BigInt, Math::Int64 and Math::Int128.
Update: Fixed bug. (0x12 is not the same as "0"x12!)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hex to decimal resulting in integer overflow
by ikegami (Patriarch) on Apr 01, 2011 at 17:55 UTC |