static void Main(string[] args) { sbyte word = 0b00001100; Console.WriteLine(Convert.ToString(word, 2)); Console.WriteLine(word.GetBit(7)); //for (int i = 0; i <= 31; ++i) // Console.WriteLine(word.GetBit(i)); Console.WriteLine(Convert.ToString(word.SetBit(1, 7), 2)); Console.WriteLine(word.GetBit(7)); }
public void GetBit0Test_sbyte() { sbyte w = 0b01001010; bool expected = false; bool actual = w.GetBit(0); Assert.AreEqual(expected, actual); }
public void GetBitTest_sbyte() { sbyte w = 0b01001010; bool expected = true; bool actual = w.GetBit(3); Assert.AreEqual(expected, actual); }
public void GetBit_PositioLessThan0_Exeption_Test_sbyte() { sbyte w = -100; Assert.ThrowsException <ArgumentOutOfRangeException>(() => w.GetBit(-1)); }
public void GetBit_PositioGreaterThanSize_Exeption_Test_sbyte() { sbyte w = 0b01001010; Assert.ThrowsException <ArgumentOutOfRangeException>(() => w.GetBit(8)); }