When I give to a variable such value: e = 17|-15;
, I get -15 as an answer after compiling.I can\'t understand what arithmetic c++ uses. How does it perform a
It does OR operations on negative numbers the same way it does so on positive numbers. The numbers are almost certainly represented in two's-complement form, which gives you these values:
17 = 0000000000010001 -15 = 1111111111110001
As you can see, all the bits of 17 are already set in −15, so the result of combining them is again −15.