title: Finding 1's complement
body: <p>I am trying to make a program to calculate 1's complement after entering a binary number.
  This is what I have to far:</p>
  
  <pre><code>import java.util.Scanner;
  public class BitWiseComplement {
      public static void main(String[] args) {
          Scanner keysIn = new Scanner(System.in);
          System.out.println("Please enter your number: ");
          long originalNum = keysIn.nextLong();
          System.out.println(~originalNum);
    }
  }
  </code></pre>
  
  <p>However, when I enter 0111011, I get -111012. I thought the ~ operator was supposed to invert the number so that all 0s are 1s and all 1s are 0s. </p>
  
  <p>Any help?</p>