in reply to Convert Hex to BigInt
Try this
Though we shouldn't have to make all those new calls in the loop. Even according to the documentation, which says the methods return objects. Oh well, it seems to work. Perhaps you could suggest they support new with a hex value, as that does not seem wholly unreasonable.use Math::BigInt; $d = Math::BigInt->new(0); foreach my $h (split'','0x0081def509be'){ #UPDATE: Doh! Thinking base 10, this now # agrees with IO's result. It also # handles arbitrarily large hex values. # $d = Math::BigInt->new($d->bmul(10)); $d = Math::BigInt->new($d->bmul(16)); $d = Math::BigInt->new($d->badd(hex($h))); printf " :: %i : $d \n", hex($h); } print $d, "\n";
--
perl -pe "s/\b;([st])/'\1/mg"
|
|---|