in reply to Converting an array of bytes into a BigInt - speed considerations

I guess that it is probably the exponentiation that slows you down (as bart remarked). The easiest thing I can think of would be to hardcode the powers of 256 in a separate array. So the loop would become:

my @factors = (1, 256, 65536, ...); foreach my $a (@array) { $result += $a * $factors[$count++]; }
HTH,

pike

  • Comment on Re: Converting an array of bytes into a BigInt - speed considerations
  • Download Code