home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book Home Programming PerlSearch this book

32.32. 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.)



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.