+ 1
The ~(Complement) Operater
How this complement operator works https://code.sololearn.com/cy9GB7FHG9US/?ref=app
5 Answers
+ 2
Result is the operand's value with its sign inverted (negative <-> positive) subtracted by 1.
In your code ...
3 with sign inverted becomes -3, subtract by 1, becomes -4.
-4 with sign inverted becomed 4, subtract by 1, becomes 3.
+ 2
Irfansari,
See the top answer in the following page
https://www.quora.com/How-does-the-bitwise-complement-operator-work
+ 1
Ipang but what is going on in computer
+ 1
The bitwise not (~) operator simply flips all bits to their opposite values. If a bit is 0, it becomes 1. If a bit is 1, it becomes 0.
It is also called one's complement.
What you see in your program is the result of taking the one's complement of 3, and displaying it as two's complement. Two's complement is the most common way to interpret negative values. It will always be off by 1 from the one's complement.
+ 1
Nice what a think it's a very good programerš