I’m trying to Sum of two large numbers for some reason
<?php
$a = 50000000000.000000000000000000;
$b = 100000000000000000000000000000;
$sum = $a+$b;
echo $sum;
But the output appears like this:
1.0E+290
Is there a function that can be used to sum two large numbers?
>Solution :
You can use bcmath extension that provide functions to perform mathematical operations with numbers of any size and precision up to 2147483647 decimal digits, if there is sufficient memory.
Example :
<?php
$a = '50000000000.000000000000000000';
$b = '100000000000000000000000000000';
echo bcadd($a,$b);
// result : 100000000000000000050000000000