Exemple #1
0
        public static string AddDecimal(string decimal1, string decimal2)
        {
            int need1 = CalculateUtilities.ConvertDecimal(ref decimal1);
            int need2 = CalculateUtilities.ConvertDecimal(ref decimal2);
            int need  = 0;

            if (need1 > need2)
            {
                need = need1;
                int temp = need1 - need2;
                for (int i = 0; i < temp; i++)
                {
                    decimal2 += '0';
                }
            }
            else
            {
                need = need2;
                int temp = need2 - need1;
                for (int i = 0; i < temp; i++)
                {
                    decimal1 += '0';
                }
            }
            string result = AddInteger(decimal1, decimal2);

            if (need == 0)
            {
                return(result);
            }
            return(UnaryOperatorService.Devision10(result, need));
        }
Exemple #2
0
        public static string MutipilationDecimal(string decimal1, string decimal2)
        {
            if (decimal2 == "0")
            {
                throw new DivideByZeroException();
            }
            int    need1  = CalculateUtilities.ConvertDecimal(ref decimal1);
            int    need2  = CalculateUtilities.ConvertDecimal(ref decimal2);
            int    need   = need1 + need2;
            string result = MutipilationInteger(decimal1, decimal2);

            if (need == 0)
            {
                return(result);
            }
            return(UnaryOperatorService.Devision10(result, need));
        }
Exemple #3
0
 public string UnaryHandler(string element, string function)
 {
     element = CalculateUtilities.StandardizedDisplay(element);
     if (function.Contains("precent"))
     {
         return(UnaryOperatorService.Devision10(element, 2));
     }
     else if (function.Contains("inverse"))
     {
         return(UnaryOperatorService.InverseNumber(element));
     }
     else if (function.Contains("exponential"))
     {
         return(UnaryOperatorService.ExponentialDecimal(element, function[function.Length - 1] - '0'));
     }
     else if (function.Contains("square"))
     {
         return(UnaryOperatorService.SquareDecimal(element, function[function.Length - 1] - '0', 10));
     }
     else
     {
         throw new Exception();
     }
 }