Bug #73581 [Opn]: number_format allows for -0.00
| From: | bowersbros at gmail dot com | Date: | Tue, 22 Nov 2016 15:31:22 +0000 |
| Subject: | Bug #73581 [Opn]: number_format allows for -0.00 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-205547@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73581&edit=1
ID: 73581
User updated by: bowersbros at gmail dot com
Reported by: bowersbros at gmail dot com
Summary: number_format allows for -0.00
Status: Open
Type: Bug
-Package: *General Issues
+Package: Math related
Operating System: Ubuntu 14.04
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Changed to be math
Previous Comments:
------------------------------------------------------------------------
[2016-11-22 15:30:48] bowersbros at gmail dot com
Description:
------------
number_format fixes the number output from many decimals to a defined number.
If you were to have a sufficiently small negative number, it will round and display
"-0.00". I'd expect it to become zero,
This has already been reported at https://bugs.php.net/bug.php?id=23866 however that
is 13 years ago and it has not received a response.
Test script:
---------------
https://3v4l.org/oU2tg
<?php
$number = -1.15E-15;
var_dump($number);
var_dump(number_format($number, 2));
Expected result:
----------------
"0.00"
Actual result:
--------------
"-0.00"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73581&edit=1