public static string ExponentialDecimal(string number, int exponent)
 {
     if (exponent == 1)
     {
         return(number);
     }
     else if (exponent % 2 == 0)
     {
         string result = ExponentialDecimal(number, exponent / 2);
         return(BinaryOperatorService.MutipilationDecimal(result, result));
     }
     else
     {
         string result = ExponentialDecimal(number, exponent / 2);
         result = BinaryOperatorService.MutipilationDecimal(result, result);
         return(BinaryOperatorService.MutipilationDecimal(result, number));
     }
 }
Example #2
0
        public string BinaryHandler(string element1, string element2, string function)
        {
            element1 = CalculateUtilities.StandardizedDisplay(element1);
            element2 = CalculateUtilities.StandardizedDisplay(element2);
            switch (function)
            {
            case "add":
                return(BinaryOperatorService.AddDecimal(element1, element2));

            case "subtract":
                return(BinaryOperatorService.SubtractDecimal(element1, element2));

            case "mutipilation":
                return(BinaryOperatorService.MutipilationDecimal(element1, element2));

            case "devision":
                return(BinaryOperatorService.DivisionDecimal(element1, element2, 20));

            default:
                throw new Exception();
            }
        }
 public static string InverseNumber(string number)
 {
     return(BinaryOperatorService.DivisionDecimal("1", number, 20));
 }