[Share] PHPint super large overflow integer addition and subtraction operation function, if there is a better method, you are welcome to explore and share an overflow integer addition and subtraction operation function, just written, you can use this to add or subtract overflow integers. Unfortunately, there is too much code, and there is only addition and subtraction operations, and there is no multiplication and division remainder. In fact, there is a simpler way to use the SQL database: SELECT & nbsp; n1 + [share] PHP int super large overflow integer addition and subtraction functions, if there is a better way to explore
Share an operation function for adding or subtracting overflow integers. you can use this function to add or subtract overflow integers.
Unfortunately:
Too many codes;
2. there is only addition and subtraction, and there is no multiplication and division remainder;
In fact, another easier way is to use the SQL database: SELECT n1 + n2;
mysql> SELECT 11234123413241341234123412341234+1;
+------------------------------------+
| 11234123413241341234123412341234+1 |
+------------------------------------+
| 11234123413241341234123412341235 |
+------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT 11234123413241341234123412341234*12341234123;
+----------------------------------------------+
| 11234123413241341234123412341234*12341234123 |
+----------------------------------------------+
| 138642947209487270472850788378836360727782 |
+----------------------------------------------+
1 row in set (0.00 sec)
If you have a better method, please reply or send me a message at any time. Welcome to explore.
/* big int operate [by fuzb 20130826] */
function bigintO($num1,$op,$num2)
{
$arr = array();
$endop = '';
$num1o = $num1;
$num2o = $num2;
if($num1 < 0)
{
$c1 = -1;
$num1 = preg_replace('/^(-)/','',$num1);
} else {
$c1 = 1;
}
if($num2 < 0)
{
$c2 = -1;
$num2 = preg_replace('/^(-)/','',$num2);
} else {
$c2 = 1;
}
$len1 = strlen($num1);
$len2 = strlen($num2);
$len = max(strlen($num1),strlen($num2));
if($len1 < $len) $num1 = str_pad('0',$len - $len1).$num1;
if($len2 < $len) $num2 = str_pad('0',$len - $len2).$num2;
if($op == '+')
{
if($c1 == $c2)
{