Explain Me This Concept

Q12. bitmask ~
int x = ~10;
What will be the value of x?

@amangoel987357
hello Aman,
it ( ~ ) basically takes ones complement of the number (i.e invert all the bits)
image

In ur case x will contain ones complement of 10 which is -11.

for similar techniques pls refer this article ->https://www.geeksforgeeks.org/bitwise-hacks-for-competitive-programming/

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.