If you want to use large integers, you can use bigint , which you can use for the file:
use bigint;
or only a limited amount:
{ use bigint; ...; }
If you need large floating point numbers as well as large integers, you can use the bignum pragma in the same way. In any case, this will slow down your program a bit (or significantly if you do a lot of math), so you should only use them for the parts where you really need them. However, faster is not better than right. :)
If you want very precise control over numbers using big* math, you can use the base classes that implement them and create objects yourself, rather than applying big* semantics to everything. See what Math::Big* modules are.
I talk more about this in the Benchmarking Mastering Perl chapter, because computers that are too fast are currently using factorial as a slow function, and we have also added a large numbers section to the upcoming Effective Perl Programming, 2nd Edition .
brian d foy
source share