I know this question was already posted but the answer was a trick to solve the given problem some other way, but the core question remained unanswered.
Thats because -0 = 0? But I can see how an algorithm can run into problem if this aspect is over-looked. So I suggest using setdiff instead of negative indices.