php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32518 number_format returns -0,00
Submitted: 2005-03-31 16:44 UTC Modified: 2005-04-03 18:04 UTC
Votes:9
Avg. Score:4.7 ± 0.9
Reproduced:9 of 9 (100.0%)
Same Version:1 (11.1%)
Same OS:6 (66.7%)
From: php at mijav dot dk Assigned:
Status: Wont fix Package: Math related
PHP Version: 4CVS, 5CVS (2005-03-31) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at mijav dot dk
New email:
PHP Version: OS:

 

 [2005-03-31 16:44 UTC] php at mijav dot dk
Description:
------------
Tthe number -0,00 is non-existent and inconsistent, pointed out in a duplicate bug report, and therefore the output is jibberish.

If you do a number_format(round($foo,2), 2, ",", "."); then the output will be correct/as expected. This is also why number_format should be considered buggy. If number_format rounds before formatting, it should be consistent: -0,00 isn't consistent since -0,505 gets rounded to -0,51.

Please re-evaluate the situation. The output -0,00 is not useful.

Please note that our production server uses 4.3.8, but the Changelog reports nothing about a fix, and the previous bug report was marked Bogus.

Reproduce code:
---------------
<?
echo number_format(-0.0012499999998, 2, ",", ".");
?>

Expected result:
----------------
0,00

Actual result:
--------------
-0,00

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 05:01:33 2024 UTC