File: BigInteger.php
Source Location: /Math_BigInteger1.0.2/BigInteger.php
Classes:
Math_BigInteger
PurePHP arbitrary precision integer arithmetic library. Supports base2, base10, base16, and base256 numbers.
Page Details:
PurePHP arbitrary precision integer arithmetic library.
Supports base2, base10, base16, and base256 numbers. Uses the GMP or BCMath extensions, if available, and an internal implementation, otherwise. PHP versions 4 and 5 {@ mode) Math_BigInteger uses base2**26 to perform operations such as multiplication and division and base2**52 (ie. two base 2**26 digits) to perform addition and subtraction. Because the largest possible value when multiplying two base2**26 numbers together is a base2**52 number, double precision floating point numbers  numbers that should be supported on most hardware and whose significand is 53 bits  are used. As a consequence, bitwise operators such as >> and << cannot be used, nor can the modulo operator %, which only supports integers. Although this fact will slow this library down, the fact that such a high base is being used should more than compensate. When PHP version 6 is officially released, we'll be able to use 64bit integers. This should, once again, allow bitwise operators, and will increase the maximum possible base to 2**31 (or 2**62 for addition / subtraction). Numbers are stored in little endian format. ie. (new Math_BigInteger(pow(2, 26)))>value = array(0, 1) Useful resources are as follows: Here's an example of how to use this library: <?php
include('Math/BigInteger.php');
$c = $a>add($b);
echo $c>toString(); // outputs 5
?>
LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Documentation generated on Mon, 11 Mar 2019 15:56:35 0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
