I was looking for some bit-Operations in Java and found the ~ operator. I found following explenation:
~a results from a, by inverting all bits of a
So when I make a System.out.println(~1)
, why is the output -2?
As 0001 = 1 after inverting it should be 1110