Bug #78187 [Opn->Nab]: Exponentiation operator gives incorrect result

From: Date: Thu, 20 Jun 2019 08:45:02 +0000
Subject: Bug #78187 [Opn->Nab]: Exponentiation operator gives incorrect result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221410@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78187&edit=1 ID: 78187 Updated by: nikic@php.net Reported by: francis dot crossen at gmail dot com Summary: Exponentiation operator gives incorrect result -Status: Open +Status: Not a bug Type: Bug Package: *Math Functions Operating System: n/a PHP Version: 7.3.6 Block user comment: N Private report: N New Comment: -1 ** 2 is -(1**2). I would recommend to avoid spaces around ** to indicate that this is a high-precedence operator. Previous Comments: ------------------------------------------------------------------------ [2019-06-20 08:40:45] francis dot crossen at gmail dot com Description: ------------ Tested in PHP shell on Linux and Windows Test script: --------------- <?php // expect 1 echo -1 * -1 . PHP_EOL; echo pow(-1, 2) . PHP_EOL; echo -1 ** 2 . PHP_EOL; // expect 49 echo -7 * -7 . PHP_EOL; echo pow(-7, 2) . PHP_EOL; echo -7 ** 2 . PHP_EOL; ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78187&edit=1

« previous php.bugs (#221410) next »