logicoperatorsbitwise-operatorsadditionbinary-operators

I'm not sure how this works, never seen such an operator "= -"


I was reading someone's code and found out that he wrote the code (below following).
for example:

operandA = -operandA;

That works but I don't understand how this operator is working. Can anyone give any similar idea please?

In the program's logic, the given statement changes the movement of X (operandA) to reverse direction when it hits something.


Solution

  • I believe it is just setting operandA to the negative of operandA