public static void B() { Console.WriteLine("(B) Using WriteNum method."); BigNum bigNum1a = new BigNum(); bigNum1a.ReadNum("0101"); BigNum bigNum2a = new BigNum(); bigNum2a.ReadNum(new List <int> { 399, 385 }); List <int> bigNum1PositionsOf1s = bigNum1a.WriteNum1sPosition(); List <int> bigNum2PositionsOf1s = bigNum2a.WriteNum1sPosition(); Console.Write("first number 1 digit positions are at: "); foreach (var pos in bigNum1PositionsOf1s) { Console.Write(pos); Console.Write(","); } Console.WriteLine(); Console.Write("second number 1 digit positions are at: "); foreach (var pos in bigNum2PositionsOf1s) { Console.Write(pos); Console.Write(","); } Console.WriteLine(); }
public static void PrintNumberInPowersOfTwo(BigNum num) { List <int> positionsOf1s = num.WriteNum1sPosition(); for (int i = 0; i < positionsOf1s.Count - 1; ++i) { Console.Write($"2^{GlobalVariables.MAX_NUM - positionsOf1s[i] - 1} + "); } Console.WriteLine($"2^{GlobalVariables.MAX_NUM - positionsOf1s[positionsOf1s.Count - 1] - 1}"); }