PHP calculates two exceptionally large integer instance codes

Source: Internet
Author: User
This article mainly introduces the PHP calculation of two very large integer instance code, has a certain reference value, now share to everyone, the need for friends can refer to

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);

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.