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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

Pull requests:

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 12:01:29 2025 UTC