Math::BigInt

use Math::BigInt;
$i = Math::BigInt->new($string);

use Math::BigInt ':constant';
print 2**200;

This prints:

+1606938044258990275541962092341162602522202993782792835301376

The Math::BigInt module provides objects that represent integers with arbitrary precision and overloaded arithmetical operators. Create these objects using the new constructor, or, within a lexical scope, by importing the special value ":constant", after which all numeric literals through the end of that lexical scope are treated as Math::BigInt objects. All standard integer operators are implemented, including (as of the 5.6 release of Perl) the bitwise logical operators. Under the current implementation, this module is not what you'd call blazingly fast, but this may be addressed in the future. (We'd like to see you how fast you are at calculating 2**200 in your head.)

Get Programming Perl, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.