Bug #73581 [Opn->Wfx]: number_format allows for -0.00
| From: | krakjoe@php.net | Date: | Sun, 08 Jan 2017 17:19:58 +0000 |
| Subject: | Bug #73581 [Opn->Wfx]: number_format allows for -0.00 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206396@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
Updated by: krakjoe@php.net
Reported by: bowersbros at gmail dot com
Summary: number_format allows for -0.00
-Status: Open
+Status: Wont fix
Type: Bug
Package: Math related
Operating System: Ubuntu 14.04
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Github comments: https://github.com/php/php-src/pull/2220
Internals discussion: http://externals.io/thread/522#email-13262
Previous Comments:
------------------------------------------------------------------------
[2016-11-22 15:31:22] bowersbros at gmail dot com
Changed to be math
------------------------------------------------------------------------
[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