title: Bitwise "~" Operator in C#
body: <p>Consider this unit test code:</p>
  
  <pre><code>    [TestMethod]
      public void RunNotTest()
      {
  
          // 10101100 = 128 + 32 + 8 + 4 = 172
          byte b = 172;
  
          // 01010011 = 64 + 16 + 2 + 1 = 83
          Assert.AreEqual(83, (byte)~b);
      }
  </code></pre>
  
  <p>This test passes. However without the byte cast it fails because the "~" operator returns a value of -173. Why is this?</p>