Req #76578 [Wfx]: ** operator and negative base

From: Date: Wed, 04 Jul 2018 18:49:24 +0000
Subject: Req #76578 [Wfx]: ** operator and negative base
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216139@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76578&edit=1 ID: 76578 Updated by: rasmus@php.net Reported by: amenshchikov at gmail dot com Summary: ** operator and negative base Status: Wont fix Type: Feature/Change Request Package: *General Issues Operating System: Debian 9 PHP Version: 7.2.7 Block user comment: N Private report: N New Comment: Or in other words, what you are doing is -(9 ** 0.5) which is indeed -3. If you really mean to raise -9 to 0.5, do (-9)**0.5 and you will see you get NAN Previous Comments: ------------------------------------------------------------------------ [2018-07-04 12:17:57] requinix@php.net ** having higher precedence than - was specifically discussed when the operator was being added. http://php.net/manual/en/language.operators.precedence.php https://wiki.php.net/rfc/pow-operator ------------------------------------------------------------------------ [2018-07-04 12:13:07] amenshchikov at gmail dot com Description: ------------ --- From manual page: http://www.php.net/language.operators.arithmetic --- When I try to raise number -9 to the power of 0.5 (take a root of even degree), I have -3 as result. But I think that NaN should be a more correct in this case. Test script: --------------- echo -9**0.5; Expected result: ---------------- NAN Actual result: -------------- -3 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76578&edit=1

« previous php.bugs (#216139) next »