Req #69161 [Opn->Csd]: Removing Signed Zeros - number_format

From: Date: Sun, 10 Sep 2017 14:55:50 +0000
Subject: Req #69161 [Opn->Csd]: Removing Signed Zeros - number_format
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211028@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69161&edit=1 ID: 69161 Updated by: cmb@php.net Reported by: tom at r dot je Summary: Removing Signed Zeros - number_format -Status: Open +Status: Closed Type: Feature/Change Request Package: *General Issues Operating System: Linux PHP Version: All -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > 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>. Previous Comments: ------------------------------------------------------------------------ [2015-03-02 16:01:29] 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69161&edit=1

« previous php.bugs (#211028) next »