Re: Power operator, why does -2**3 throws?

2016-10-24 Thread Tom Mitchell
This "should" be correct in the context of correct mathematics. Expectations and correctness must bias toward correctness. Math/Algebra has been one of the weak points of the web so it makes sense to toss an error and demand the programmer make his intention clear. It also helps with testing to

Re: Power operator, why does -2**3 throws?

2016-10-20 Thread Claude Pache
ll throw for similar reason). >>>> >>>> Also argument that it's inconsistent with Math.pow(-2, 2), is total miss >>>> in >>>> my eyes. >>>> I believe to most programmers `Math.pow(-2, 2)`, translates to >>>> `(-2)**(2

Re: Power operator, why does -2**3 throws?

2016-10-20 Thread Kevin Smith
evious > >>> case where one will throw for similar reason). > >>> > >>> Also argument that it's inconsistent with Math.pow(-2, 2), is total > miss > >>> in > >>> my eyes. > >>> I believe to most programmers `Math.pow(-2, 2)`

Re: Power operator, why does -2**3 throws?

2016-10-20 Thread medikoo
e. >>> com/Power-operator-why-does-2-3-throws-tp359609p359731.html >>> Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at >>> Nabble.com. >>> _______ >>> es-discuss mailing list >>> >> es-discuss@ >>> h

Re: Power operator, why does -2**3 throws?

2016-10-18 Thread Steve Fink
)` intuitively translates to `(a ? b : c)**(2)` and not to `a ? b : c**2` -- View this message in context: http://mozilla.6506.n7.nabble. com/Power-operator-why-does-2-3-throws-tp359609p359731.html Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com

Re: Power operator, why does -2**3 throws?

2016-10-18 Thread medikoo
intuitively translates to `(a ? b : >> c)**(2)` and not to `a ? b : c**2` >> >> >> >> >> -- >> View this message in context: http://mozilla.6506.n7.nabble. >> com/Power-operator-why-does-2-3-throws-tp359609p359731.html >> Sent from the Mozilla - ECMAS

Re: Power operator, why does -2**3 throws?

2016-10-18 Thread Jordan Harband
s in > my eyes. > I believe to most programmers `Math.pow(-2, 2)`, translates to `(-2)**(2)` > and not to `-2**2`, > same as `Math.pow(a ? b : c, 2)` intuitively translates to `(a ? b : > c)**(2)` and not to `a ? b : c**2` > > > > > -- > View this message in context: ht

Re: Power operator, why does -2**3 throws?

2016-10-18 Thread medikoo
this message in context: http://mozilla.6506.n7.nabble.com/Power-operator-why-does-2-3-throws-tp359609p359731.html Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com. ___ es-discuss mailing list es-discuss@mozilla.org https

Re: Power operator, why does -2**3 throws?

2016-10-17 Thread Leo Balter
If -2 ** 2 returned me -4 in JS I would be confused. JS is not a math language, it's a programming language. We have basic math operations on its syntax and that's fine. > In the same vein, you have `pow(1+1, 2) == 4` but `1+1 ** 2 == 2`, because the latter is interpreted as `1+(1 ** 2)`. Where

Re: Power operator, why does -2**3 throws?

2016-10-14 Thread Claude Pache
> Le 14 oct. 2016 à 16:52, Rick Waldron a écrit : > > Python is also inconsistent: > > >>> pow(-2, 2) > 4 > >>> -2 ** 2 > -4 > >>> This is not inconsistency, but that follows from operator precedence rules (those used in mathematics, not in C). In the same vein, you

Re: Power operator, why does -2**3 throws?

2016-10-14 Thread Rick Waldron
Here's some more specific notes: On Fri, Oct 14, 2016 at 7:31 AM Cyril Auburtin wrote: > I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be > like `-(2**3)` > Math.pow(-2, 3) === -8 Math.pow(-2, 2) === 4 To get -4: -Math.pow(-2, 2) > Firefox

Re: Power operator, why does -2**3 throws?

2016-10-14 Thread Rick Waldron
On Fri, Oct 14, 2016 at 7:31 AM Cyril Auburtin wrote: > I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be > like `-(2**3)` > This was discussed extensively during the design process and determined that requiring user code to be explicit about

Re: Power operator, why does -2**3 throws?

2016-10-14 Thread Cyril Auburtin
I was testing something https://caub.github.io/misc/calculator, and I didn't see how it would be a problem to have the precedence of ** higher than unaries. But at least I'm happy something like (2).pow(3) wasn't chosen. Thanks anyway and sorry for discussing something already frozen in spec

Re: Power operator, why does -2**3 throws?

2016-10-14 Thread Cyril Auburtin
Ah, ok, a bit sad because all more scientific languages, and python too, all math books, all will use `-e^3` for meaning `-(e^3)` (^ or **), because it's just `-exp(3)` or `-pow(E, 3)` and `(-1)^n` otherwise, when we want to take the signs with. If you wanted to avoid any confusion you could

Re: Power operator, why does -2**3 throws?

2016-10-14 Thread Bergi
Cyril Auburtin schrieb: I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be like `-(2**3)` You would, others would not. -2 ** 2 clearly should return 4, shouldn't it? Is there a reason for this restriction? Python does it `-2**3` fine Because of the ambiguity it has

Re: Power operator, why does -2**3 throws?

2016-10-14 Thread Cyril Auburtin
What does it change if it handles floats? I just checked https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence unary + is 16, while exponentiation is 15, so the opposite order that I thought 2016-10-14 13:37 GMT+02:00 J Decker : >

Re: Power operator, why does -2**3 throws?

2016-10-14 Thread J Decker
probably because it's floating point native not integer like you'd think, so -2.0001 ** 3 is hard? On Fri, Oct 14, 2016 at 4:30 AM, Cyril Auburtin wrote: > I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be > like `-(2**3)` > > Firefox gives

Power operator, why does -2**3 throws?

2016-10-14 Thread Cyril Auburtin
I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be like `-(2**3)` Firefox gives a clearer error then Chrome with: > SyntaxError: unparenthesized unary expression can't appear on the left-hand side of '**' Is there a reason for this restriction? Python does it `-2**3` fine