+ 2
3rd Jul 2016, 7:56 AM
sourav h
sourav h - avatar
3 Respuestas
+ 8
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 To round up your question, the unary + is used to prefix a variable in order to multiply the value by +1. The use of it however is not needed.
3rd Jul 2016, 8:27 AM
Gershon Fosu
Gershon Fosu - avatar
0
Thanks Gershon
3rd Jul 2016, 11:06 AM
sourav h
sourav h - avatar
0
(+1) (-2) unary operator operates over one number only
5th Nov 2016, 9:58 AM
Dinesh Devaki
Dinesh Devaki - avatar