Re: Re: power operator (again)
| From: | Rasmus Lerdorf | Date: | Thu, 19 Dec 2013 21:58:20 +0000 |
| Subject: | Re: Re: power operator (again) | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70763@lists.php.net to get a copy of this message | ||
On 12/19/2013 04:50 PM, Kris Craig wrote:
> I believe that, especially for a KISS language like PHP, our top priority
> with math operators should be to match arithmetic laws as closely and as
> intuitively as possible. The average PHP developer is going to do -3 ** 2
> and expect a result of 9, not -9, and rightly so I think.
No, the average PHP developer is going to do $var ** 2 and it will
behave exactly as they expect with negative values. Yes, in the very
rare case that someone for some reason hardcodes a negative literal
there, they are going to have to learn about operator precedence because
we really can't have 0 - 3**2 be different from - 3**2.
-Rasmus