Edit report at https://bugs.php.net/bug.php?id=64038&edit=1
ID: 64038 Updated by: [email protected] Reported by: nicolas dot giraud at actiane dot com Summary: number_format isn't correct with big numbers -Status: Open +Status: Not a bug Type: Bug Package: Unknown/Other Function PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Not much we can do about that. number_format() takes a float and you are overflowing a float with your huge value. Since you already have it as a string, you could just throw a regex at it. Something like: preg_replace("/(?<=\d)(?=(\d{3})+(?!\d))/",",",$number); Previous Comments: ------------------------------------------------------------------------ [2013-01-21 16:04:34] nicolas dot giraud at actiane dot com Description: ------------ The number_format function don't give the good result with good format, maybe because of cast in float that kills precision. Test script: --------------- <?php $number = '123456789012345678901234567890'; $formatted = number_format($number, 2, '.', ' '); echo $formatted; ?> Expected result: ---------------- 123 456 789 012 345 678 901 234 567 890.00 Actual result: -------------- 123 456 789 012 345 660 285 533 552 640.00 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64038&edit=1
