/// <summary> /// Метод DecimalToBinary осуществляет перевод чисел с десятиричной в двоичную систему исчесления /// </summary> /// <typeparam name="Type">Входящее десятиричное число</typeparam> /// <returns>Возращает двоичное представление десятиричного числа</returns> public Int32 DecimalToBinary <Type>(Type type) { Type modulo; BinarySystem <Type> binary = new BinarySystem <Type>(); try { while (BooleanFunctions <Type, Int32, Boolean> .Greater(type, 0)) { modulo = ArithmeticFunctionsExcellent <Type, Int32> .ModuloTwo(type, 2); type = ArithmeticFunctionsExcellent <Type, Int32> .DivideTwo(type, 2); binary.Binary.Add(modulo); } } catch (InvalidOperationException e) { Console.WriteLine(e.InnerException); } Int32 Back(List <Type> norm) { Type[] s = new Type[norm.Count()]; for (Int32 i = norm.Count() - 1; i >= 0; i--) { s[norm.Count() - 1 - i] = norm[i]; } return(Convert.ToInt32(String.Join <Type>("", s))); } return(Back(binary.Binary)); }
private Int32 Count <Type>(Type num, Int32 seed, Int32 modulo) where Type : struct { if (BooleanFunctions <Type, Int32, Boolean> .NotEquals(ArithmeticFunctionsExcellent <Type, Int32> .DivideTwo(num, modulo), 0)) { return(Count(ArithmeticFunctionsExcellent <Type, Int32> .DivideTwo(num, modulo), seed++, modulo)); } else { return(seed); } }
/// <summary> /// Метод QuadraticEquationFunc производит решение квадратного уровнения /// </summary> /// <param name="a">Первый коэффициент</param> /// <param name="b">Второй коэффициент</param> /// <param name="c">Свободный член</param> /// <returns>Возращает массив коэфициентов</returns> public static Double[] QuadraticEquationFunc(Double a, Double b, Double c) { Double d = ArithmeticFunctions <Double> .DivideTwo(ArithmeticFunctions <Double> .MultiplyTwo(b, b), ArithmeticFunctionsExcellent <Double, Double> .MultiplyTwo(ArithmeticFunctionsExcellent <Double, Int32> .MultiplyTwo(a, 4), c)); if (d > 0) { Double x1 = (-b + Math.Sqrt(d)) / 2 / a; Double x2 = (-b - Math.Sqrt(d)) / 2 / a; return(new Double[] { x1, x2 }); } else if (d == 0) { Double x1 = b / 2 / a; Double x2 = b / 2 / a; return(new Double[] { x1, x2 }); } return(null); }