php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69161 Removing Signed Zeros - number_format
Submitted: 2015-03-02 16:01 UTC Modified: 2017-09-10 14:55 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: tom at r dot je Assigned: cmb (profile)
Status: Closed Package: *General Issues
PHP Version: All OS: Linux
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: tom at r dot je
New email:
PHP Version: OS:

 

 [2015-03-02 16:01 UTC] tom at r dot je
Description:
------------
It's possible to get a signed zero:

<?php
echo round(-0.0001, 2); // -0
?>

This is valid according to IEEE 754 so probably shouldn't be changed internally. However, for display purposes, "-0" is needlessly confusing.

There's no simple way of removing it. I can call abs($num) but I need an if statement to only call abs($num); when $num is -0. 

My proposal is that number_format, which is used for display purposes, changes -0 into +0.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-11 09:03 UTC] demon@php.net
-PHP Version: 5.6.6 +PHP Version: All
 [2015-03-11 09:30 UTC] demon@php.net
-Assigned To: +Assigned To: demon
 [2015-03-11 13:06 UTC] demon@php.net
-Status: Assigned +Status: Open -Assigned To: demon +Assigned To:
 [2017-09-10 14:55 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2017-09-10 14:55 UTC] cmb@php.net
> My proposal is that number_format, which is used for display
> purposes, changes -0 into +0.

A respective RFC has been accepted and implemented (available as
of PHP 7.2.0):
<https://wiki.php.net/rfc/number_format_negative_zero>.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 15:00:01 2026 UTC