Here are the operator precedence rules: http://docs.julialang.org/en/release-0.3/manual/mathematical-operations/?highlight=operators#operator-precedence
so it's pretty clear that -1^2==-1 But for sure, it can be a bit confusing how the `-` is parsed: julia> -1*-1 1 is probably parsed as: julia> -(1*(-1)) 1 This is a bit confusing as now the second `-` binds tighter than `*`. Probably because -(1*-)1 does not make sense. Maybe `1*-1` should be a syntax error to be more consistent? More corner cases: julia> 1+-1 0 julia> 1--1 ERROR: -- not defined julia> 1-(-1) 2 On Thu, 2014-10-23 at 10:05, Nils Gudat wrote: > As John said, this is not about handling the exponential, but about > handling the minus sign. > But this isn't some sort of Julia quirk: > > MATLAB: >>> -1^2 > ans = > -1 > > Python: >>> -1**2 > -1 > > R: > >> -1^2[1] -1 > > > Seems pretty consistent to me!
