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