Code: Select all
[-5^2]
MapTool returns a positive 25. Wrong!
-5^2 is not the same as (-5)^2. In other words,
Code: Select all
[if(-5^2 == (-5)^2, "TRUE", "FALSE")]
Moderators: dorpond, trevor, Azhrei
Code: Select all
[-5^2]
Code: Select all
[if(-5^2 == (-5)^2, "TRUE", "FALSE")]
Um, that depends.DrVesuvius wrote:I think the confusion comes from the fact that in the expression "-5^2", the minus sign isn't really an operator, but an inherent part of the discrete number "-5".
Yep, how else (simply put) would you square -5?DrVesuvius wrote:I think the confusion comes from the fact that in the expression "-5^2", the minus sign isn't really an operator, but an inherent part of the discrete number "-5".
I've been reading up on ANTLR lately - how the rules are nested is how the precedence is defined. The MT parser grammar reads "-5^2" as (-5)^2Azhrei wrote:I looked at the grammar used by the MT parser and I don't see any specification of precedence so I can't tell. It might be that the order of the items in the file specifies the precedence...