perlfunc
root
<P>
Math::BigInt - Arbitrary size integer math package
<P>
<HR>
<P>
<PRE> use Math::BigInt;
$i = Math::BigInt->new($string);
</PRE>
<P>
<PRE> $i->bneg return BINT negation
$i->babs return BINT absolute value
$i->bcmp(BINT) return CODE compare numbers (undef,<
<P>
All basic math operations are overloaded if you declare your big integers
as
<P>
<PRE> $i = new Math::BigInt '123 456 789 123 456 789';
</PRE>
<DL>
<DT><STRONG><A NAME="item_Canonical">Canonical notation</A></STRONG><P>
<DD>
Big integer value are strings of the form <CODE>/^[+-]\d+$/</CODE> with leading zeros suppressed.
<P><DT><STRONG><A NAME="item_Input">Input</A></STRONG><P>
<DD>
Input values to these routines may be strings of the form
<CODE>/^\s*[+-]?[\d\s]+$/</CODE>.
<P><DT><STRONG><A NAME="item_Output">Output</A></STRONG><P>
<DD>
Output values always always in canonical form
</DL>
<P>
Actual math is done in an internal format consisting of an array whose
first element is the sign (/^[+-]$/) and whose remaining elements are base
100000 digits with the least significant digit first. The string 'NaN' is
used to represent the result when input arguments are not numbers, as well
as the result of dividing by zero.
<P>
<HR>
<H1><A NAME="EXAMPLES">EXAMPLES</A></H1>
<P>
<PRE> '+0' canonical zero value
' -123 123 123' canonical value '-123123123'
'1 23 456 7890' canonical value '+1234567890'
</PRE>
<P>
<HR>
<H1><A NAME="Autocreating_constants">Autocreating constants</A></H1>
<P>
After <CODE>use Math::BigInt ':constant'</CODE> all the integer decimal constants in the given scope are converted to <CODE>Math::BigInt</CODE>. This conversion happens at compile time.
<P>
In particular
<P>
<PRE> perl -MMath::BigInt=:constant -e 'print 2**100'
</PRE>
<P>
print the integer value of <CODE>2**100</CODE>. Note that without convertion of constants the expression 2**100 will be
calculatted as floating point number.
<P>
<HR>
<H1><A NAME="BUGS">BUGS</A></H1>
<P>
The current version of this module is a preliminary version of the real
thing that is currently (as of perl5.002) under development.
<P>
<HR>
<H1><A NAME="AUTHOR">AUTHOR</A></H1>
<P>
Mark Biggar, overloaded interface by Ilya Zakharevich.
<HR>