Beispiel #1
0
 public void SetBits_Smoke_Test()
 {
     Assert.AreEqual(4, SetBits.Count(3));
     Assert.AreEqual(9, SetBits.Count(6));
     Assert.AreEqual(12, SetBits.Count(7));
     Assert.AreEqual(13, SetBits.Count(8));
 }
        static void RunProgram(ref bool programRunning)
        {
            int n = InputHandling.ReadValue("Number to display set bits: ");

            int[] nToBase2 = BaseConversion.ConvertBase10ToBaseX(n, 2);
            OutputHandling.Message("The number of bits that are set for " + n + " is " + SetBits.CountSetBits(n));
            OutputHandling.PrintArray(nToBase2, nToBase2.Length, "Representation of " + n + " in base 2 is: ", "", "0b", false);
            OutputHandling.Question("Do you want to calculate the number of set bits of a nother number? Y / N");
            programRunning = InputHandling.QuestionOptions();
        }