Hmmm... well if it goes back to Fortran, then it's nearly as old as I am! I wonder if some compiler writer, tripping on 60s chemicals, got it wrong and his mistake has been passed from generation to generation or if, in fact, there is some very good reason for this order. Anyone got any thoughts on why it might be better in some context to evaluate exponentiation before unary negation? Or (less likely but possible) does anyone know the actual history? | [reply] |
Because unary negation is actually a multiplication?
And that everyone agrees that 4 * 3 ** 2
equals 36, and not 144?
Of course, that's just guessing. Note that
echo '-2^2' | bc
gives you 4, and not -4.
Abigail | [reply] [d/l] [select] |