Copyright (C) 2000-2012 |
Manpages Math::BigIntSection: Perl Programmers Reference Guide (3perl)Updated: 2001-02-22 Index Return to Main Contents NAMEMath::BigInt - Arbitrary size integer math packageSYNOPSISuse Math::BigInt; $i = Math::BigInt->new($string); $i->bneg return BINT negation $i->babs return BINT absolute value $i->bcmp(BINT) return CODE compare numbers (undef,<0,=0,>0) $i->badd(BINT) return BINT addition $i->bsub(BINT) return BINT subtraction $i->bmul(BINT) return BINT multiplication $i->bdiv(BINT) return (BINT,BINT) division (quo,rem) just quo if scalar $i->bmod(BINT) return BINT modulus $i->bgcd(BINT) return BINT greatest common divisor $i->bnorm return BINT normalization $i->blsft(BINT) return BINT left shift $i->brsft(BINT) return (BINT,BINT) right shift (quo,rem) just quo if scalar $i->band(BINT) return BINT bit-wise and $i->bior(BINT) return BINT bit-wise inclusive or $i->bxor(BINT) return BINT bit-wise exclusive or $i->bnot return BINT bit-wise not DESCRIPTIONAll basic math operations are overloaded if you declare your big integers as
$i = new Math::BigInt '123 456 789 123 456 789';
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. EXAMPLES'+0' canonical zero value ' -123 123 123' canonical value '-123123123' '1 23 456 7890' canonical value '+1234567890' Autocreating constantsAfter "use Math::BigInt ':constant'" all the integer decimal constants in the given scope are converted to "Math::BigInt". This conversion happens at compile time.In particular
perl -MMath::BigInt=:constant -e 'print 2**100'print the integer value of "2**100". Note that without conversion of constants the expression 2**100 will be calculated as floating point number. BUGSThe current version of this module is a preliminary version of the real thing that is currently (as of perl5.002) under development.AUTHORMark Biggar, overloaded interface by Ilya Zakharevich.
IndexThis document was created by man2html, using the manual pages. Time: 05:59:57 GMT, April 24, 2024 |