Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
The unary plus in itself doesn't do anything because multiplying anything by +1 won't change the result. E.g var = 10 var2 = -20 +var would yield 10 +var2 yields -20 The result is unchanged. It is only used in a certain scenario in which it does make a difference. The unary minus on the other hand does change the result, because -1 multiplied with another operand does change the result. If the operand is positive, it makes it negative. If the operand is negative, yields a positive version. E.g var = 2 var2 = -4 -var yields -2 -var2 yields 4
2nd Nov 2016, 9:51 AM
Waqas Asghar Bhalli
Waqas Asghar Bhalli - avatar