Bug #73581 [NEW]: number_format allows for -0.00
| From: | bowersbros at gmail dot com | Date: | Tue, 22 Nov 2016 15:30:51 +0000 |
| Subject: | Bug #73581 [NEW]: number_format allows for -0.00 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-205546@lists.php.net to get a copy of this message | ||
From: bowersbros at gmail dot com
Operating system: Ubuntu 14.04
PHP version: Irrelevant
Package: *General Issues
Bug Type: Bug
Bug description:number_format allows for -0.00
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 bug report at https://bugs.php.net/bug.php?id=73581&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73581&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73581&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73581&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73581&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73581&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73581&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73581&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73581&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73581&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73581&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73581&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73581&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73581&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73581&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73581&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73581&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73581&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73581&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73581&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73581&r=mysqlcfg