PHP calculates an integer set of extra-large numbers

Source: Internet
Author: User
This time for everyone to bring PHP to calculate the integer set of large numbers, PHP to calculate the number of extra-large digital integer set of considerations, the following is the actual case, take a look.

Needless to say, the exact code is as follows:

function Getintadd ($a, $b) {$c = "; $bCount = strlen ($b); $aCount = strlen ($a); $count = max ($bCount, $aCount); $aDiff = $count  -$aCount $bDiff = $count-$bCount; for ($i = $count-1; $i >= 0; $i-) {$aVal = $count-$i <= $aCount? intval ($a [$i -$aDiff]): 0; $bVal = $count-$i <= $bCount? Intval ($b [$i-$bDiff]): 0; $v = $aVal + $bVal, if (strlen ($c) > 0 && strlen ($c) >= $count-$i) {$c = ($v + in Tval ($c [0]). substr ($c, 1,strlen ($c)-1);} else{$c = $v. $c. ';}} return $c;} $a = ' 23490234328490289048902384908392849238 '; $b = ' 234320498324982390489328498230984982399290384902384 '; $c = Getintadd ($a, $b);p Rint_r ($c);

Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!

Recommended reading:

PHP shared memory usage and signal control use case resolution

How to add a popup box to the applet's Product Details page

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.