| Newsgroups |
php.standards |
| Message-ID |
<[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=71467&edit=1
ID: 71467
Updated by: [email protected]
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