日期:2014-05-17 浏览次数:20598 次
一代码太多;
二只有加减运算,乘除取余都没有;
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)
/* 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)
{