Req #71467 [Opn->Wfx]: -2 **2 = -4
| From: | requinix@php.net | Date: | Wed, 27 Jan 2016 23:38:14 +0000 |
| Subject: | Req #71467 [Opn->Wfx]: -2 **2 = -4 | ||
| References: | 1 | Groups: | php.standards |
| Request: | Send a blank email to standards-+get-1016@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71467&edit=1
ID: 71467
Updated by: requinix@php.net
Reported by: public at grik dot net
Summary: -2 **2 = -4
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: PHP Language Specification
Operating System: unrelated
PHP Version: 7.0.3RC1
Block user comment: N
Private report: N
New Comment:
** has higher precedence than -
http://php.net/manual/en/language.operators.precedence.php
-2 ** 2 => -(2 ** 2)
The programming world is split on whether power/exponentiation ranks higher or lower than negation -
PHP chose the higher side, which also includes Python and Perl.
Previous Comments:
------------------------------------------------------------------------
[2016-01-27 23:27:18] public at grik dot net
Description:
------------
In 5.6 the operator ** appeared, but its behavior is very unexpected.
echo -2 ** 2; gives -4
Test script:
---------------
echo -2 ** 2;
Expected result:
----------------
4
Actual result:
--------------
-4
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71467&edit=1