0

I'm testing with this code:

$numero = 60107103639850690;
echo number_format($numero,0,'','');

And the output value is: 60107103639850688

Why PHP number_format change 60107103639850690 for 60107103639850688?

I'm try with other numbers and same case:

$numero = 60107103639850550;
echo number_format($numero,0,'','');

Output: 60107103639850552

In small numbers work well.. but what happened in this cases?

Fran Bedia
  • 41
  • 4
  • 2
    Because `number_format` takes a `float` as an argument. See [explanation](https://stackoverflow.com/questions/588004/is-floating-point-math-broken). – El_Vanja Dec 14 '20 at 12:48
  • The number is too large for PHP to manage properly. – aynber Dec 14 '20 at 13:01

0 Answers0