Increase or decrease the number of overflow integers in the PHPint. if you have any better methods, you are welcome to explore.

Source: Internet
Author: User
[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)
        {

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.