Consider this unit test 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);
}
This test passes. However without the byte cast it fails because the "~" operator returns a value of -173. Why is this?