Hacker News new | ask | show | jobs
by sheept 26 days ago
JavaScript does something similar for the exponentiation operator. This is a syntax error:

    -a ** b
Someone who learned PEMDAS in school may argue it should be equivalent to -(a * b), while a programmer may be used to unary operators binding tightest, so (-a) * b.
1 comments

The unary minus isn't in PEMDAS. Besides, I have never seen anybody that interprets -2^2 as -4 instead of 4.