PHP function number_format seems to not be reliable for big numbers. It's probably a rounding issue as explained on PHP - number_format issues
The function money_format() behaves similarly.
This is the case:
$n = 1000000000000000001;
echo "\nn = $n";
$nFormat = number_format($n, 0, '.', ',');
echo "\nnFormat = $nFormat";
$nMFormat = money_format('%!i', $n);
echo "\nnMFormat = $nMFormat";
Results are:
n = 1000000000000000001
nFormat = 1,000,000,000,000,000,000
nMFormat = 1000000000000000000.00
Is there a number_format function for big numbers in PHP? Should I code myself? Do I have to deal with big numbers as strings for formatting?