Bug #70804 [Opn]: round(-0)=-0 but +round(-0)=0

From: Date: Tue, 27 Oct 2015 21:00:00 +0000
Subject: Bug #70804 [Opn]: round(-0)=-0 but +round(-0)=0
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196848@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70804&edit=1

 ID:                 70804
 Updated by:         requinix@php.net
 Reported by:        davividal at gmail dot com
-Summary:            Positive * Negative = Positive
+Summary:            round(-0)=-0 but +round(-0)=0
 Status:             Open
 Type:               Bug
 Package:            *General Issues
 Operating System:   Linux
 PHP Version:        5.6.14
 Block user comment: N
 Private report:     N

 New Comment:

Changed the summary. I take it you were originally seeing this with some multiplication?

It's not that the plus sign causes it to become positive. The same thing happens with a
negative sign too: PHP recognizes the zero and forces it to be positive.

I don't know if this counts as a bug but it certainly could qualify as a request: while -0 is a
legitimate (though unusual) floating-point number, I think that round(-0) should also force it to be
positive.


Previous Comments:
------------------------------------------------------------------------
[2015-10-27 19:41:45] davividal at gmail dot com

Description:
------------
Given a negative number, it's possible to turn it into positive by just putting a positive sign
in front of it.

Test script:
---------------
var_dump(round(-1e-99));
var_dump(+round(-1e-99));



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70804&edit=1


Thread (6 messages)

« previous php.bugs (#196848) next »