Cyril Auburtin schrieb:
I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be
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 been decided to make it a syntax error
if the two operators are used together. If you want `-(2**3)`, you have
to write it like that, and if you want `(-2)**3` you have to write it
explicitly as well.
See https://esdiscuss.org/topic/exponentiation-operator-precedence for
the full discussion.
es-discuss mailing list