It's key to learn the difference between unary operators, binary operators and ternary operators. A unary operator such as ! only takes one operand (i.e., !a). A binary operator such as / takes two operands (i.e., a / b). A ternary operator such as ?: takes three operands (i.e., a ? b : c). In order to force the condition to be evaluated as you expect it to be you need the expression to be parenthesized (!(i < j) or i >= j, but not !i < j because that is the same as ((i ? 0 : 1) < j)).
Last edited: