php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73581 number_format allows for -0.00
Submitted: 2016-11-22 15:30 UTC Modified: 2017-01-08 17:19 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bowersbros at gmail dot com Assigned:
Status: Wont fix Package: Math related
PHP Version: Irrelevant OS: Ubuntu 14.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bowersbros at gmail dot com
New email:
PHP Version: OS:

 

 [2016-11-22 15:30 UTC] 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"

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-22 15:31 UTC] bowersbros at gmail dot com
-Package: *General Issues +Package: Math related
 [2016-11-22 15:31 UTC] bowersbros at gmail dot com
Changed to be math
 [2017-01-08 17:19 UTC] krakjoe@php.net
-Status: Open +Status: Wont fix
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 14 06:01:35 2019 UTC