php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #13756 exponential ** operator
Submitted: 2001-10-19 10:36 UTC Modified: 2013-02-28 21:19 UTC
From: sander@php.net Assigned: mike (profile)
Status: Closed Package: *General Issues
PHP Version: 4.0.6 OS: n/a
Private report: No CVE-ID: None
 [2001-10-19 10:36 UTC] sander@php.net
It would be nice to have an exponential operator. ** would be a logical choice, just like in C.

Example:
echo 2**3; // prints 8

I know we have pow(), but an operator for this would be nice...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-19 11:24 UTC] hholzgra@php.net
** is Pascal, not C
 [2001-10-19 18:51 UTC] jeroen@php.net
I proposed that earlier (along with ^^) [ZendEnginge ML, june 27th & july 3rd].

Anyway, I think it should be added, there is simply no power operator now, and pow() is both a bit bugly and overloaded (both ^^ and ** at the same time).
 [2002-04-27 16:17 UTC] jimw@php.net
not going to happen. just suck it up and use pow().
 [2012-07-08 23:31 UTC] hello at wesalvaro dot com
le why not?
 [2013-02-28 11:17 UTC] tom at r dot je
Indeed! Seems very despotic just to say "No. Deal with it" with no further 
discussion or explanation why.
 [2013-02-28 17:08 UTC] nikic@php.net
@tom Exponentiation is an operation that is used too little (in PHP) to warrant adding an extra operator for it. Doing a random guess, I'd think it's used even less than the bitwise operators (and those are used quite rarely in PHP...)
 [2013-02-28 17:08 UTC] nikic@php.net
-Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: nikic
 [2013-02-28 21:19 UTC] mike@php.net
-Assigned To: nikic +Assigned To: mike
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 06:01:27 2024 UTC