in reply to dealing with large numbers

Well, it depends. Do you have 64-bit integers? Or 32-bit? If the latter, Perl will silently upgrade to floats when the number gets too large, and still be able to do lossless arithmetic up to about 53 bits (although I have to confess, I don't know whether Perl does the upgrade when 'use integer' is in effect).

I guess it shouldn't be too hard to modify your program and keep track of the largest number used during the calculation, and see how many bits this needs.