Example #1
0
        private CalculateCathe CalculateBitResult(char c1, char c2, bool carry)
        {
            CalculateCathe cathe = new CalculateCathe();

            int intResult = c1 - '0' + c2 - '0' + (carry?1:0);

            cathe.IsCarry = intResult > 1;
            cathe.Result  = Convert.ToChar((intResult % 2) + '0');

            return(cathe);
        }
Example #2
0
        public string CalculateCodeResult(string data1st, string data2st)
        {
            StringBuilder  result = new StringBuilder();
            CalculateCathe buffer = new CalculateCathe();

            for (int i = data1st.Length - 1; i >= 0; i--)
            {
                buffer = CalculateBitResult(data1st[i], data2st[i], buffer.IsCarry);
                result.Insert(0, buffer.Result);
            }

            return(result.ToString());
        }