0
Why 2--2 gives 4 in output? Can anyone explain this for me ?
6 Réponses
+ 5
Here the first '−' represents the binary subtraction operation, while the second '−' represents the unary negation of the 2 (or '−2' could be taken to mean the integer −2). Therefore, the expression is equal to : 2-(-2) which results in 4 as output
+ 1
cause minus and minus give us plus
+ 1
2-(-2) becomes 2+2 which is 4
+ 1
Well In mathematics you would have learned that negative and negative equals to positive, same is the condition here you ask python to give output for 2(negative)(negative)2 which becomes 2(positive)2 and the answer is 4 which is displayed.
0
2-(-2)
0
Look -+-=+.