Answer the question
In order to leave comments, you need to log in
&~ (ampersand with tilda) in Objective-C. How does it work and what happens when this operation is performed?
Recently I saw a construction similar to this one in someone else's code. int num = 2 &~ 100;
Please explain how it works and what happens when this operation is performed.
Thank you!
Answer the question
In order to leave comments, you need to log in
I believe that these are bit operations. 2 and (not 100).
To understand what is happening, you need to represent both numbers in binary form.
2: 10, 100: 1100100.
Next, 100 is inverted: 0011011 and the conjunction is made:
11011 & 10 = 00010
As a result, we get 2.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question