예제 #1
0
        /// <summary>
        /// Sqrt of entry
        /// </summary>
        public void Sqrt()
        {
            Entry = StandardFunctions.Sqrt(Entry);

            first      = true;
            enteredNum = true;
            overwrite  = true;
        }
예제 #2
0
        /// <summary>
        /// The reciprocal of entry (1/x)
        /// </summary>
        public void Reciprocal()
        {
            Entry = StandardFunctions.Reciprocal(Entry);

            first      = true;
            enteredNum = true;
            overwrite  = true;
        }
예제 #3
0
        /// <summary>
        /// Calculates the percentage of the previous number mostly for the purpose of adding
        /// and subtracting percents
        /// </summary>
        public void Percent()
        {
            Entry = StandardFunctions.PercentOfNumber(PreEntry, Entry);

            first      = true;
            enteredNum = true;

            overwrite = true;
        }
예제 #4
0
        /// <summary>
        /// Applies an operator to preEntry and entry
        /// </summary>
        /// <param name="operationText">Text representing the operation</param>
        public void Operation(string operationText)
        {
            if (numBase != "dec")
            {
                Entry    = ProgrammerFunctions.ConvertBase(Entry, numBase, "dec");
                PreEntry = ProgrammerFunctions.ConvertBase(PreEntry, preEntryBase, "dec");
            }

            if (enteredNum)
            {
                preEntryBase = numBase;
                if (first)
                {
                    PreEntry = Entry;
                }
                else
                {
                    if (operation == "+")
                    {
                        PreEntry = StandardFunctions.Add(PreEntry, Entry);
                    }
                    else if (operation == "-")
                    {
                        PreEntry = StandardFunctions.Subtract(PreEntry, Entry);
                    }
                    else if (operation == "*")
                    {
                        PreEntry = StandardFunctions.Multiply(PreEntry, Entry);
                    }
                    else if (operation == "/")
                    {
                        PreEntry = StandardFunctions.Divide(PreEntry, Entry);
                    }
                }
            }

            if (numBase != "dec")
            {
                PreEntry = ProgrammerFunctions.ConvertBase(PreEntry, "dec", numBase);
                //preEntryBase = numBase;
            }

            Entry      = "0";
            operation  = operationText;
            first      = false;
            enteredNum = false;
        }
예제 #5
0
        //-----------exponential-----------

        // used to square an entry
        public static string Square(string entry)
        {
            entry = StandardFunctions.Multiply(entry, entry);
            return(entry);
        }
예제 #6
0
        /// <summary>
        /// Finds new display based on previous operator
        /// </summary>
        public void Equals()
        {
            if (numBase != "dec")
            {
                Entry    = ProgrammerFunctions.ConvertBase(Entry, numBase, "dec");
                PreEntry = ProgrammerFunctions.ConvertBase(PreEntry, preEntryBase, "dec");
            }

            if (operation == "+")
            {
                Entry = StandardFunctions.Add(PreEntry, Entry);
            }
            else if (operation == "-")
            {
                Entry = StandardFunctions.Subtract(PreEntry, Entry);
            }
            else if (operation == "*")
            {
                Entry = StandardFunctions.Multiply(PreEntry, Entry);
            }
            else if (operation == "/")
            {
                Entry = StandardFunctions.Divide(PreEntry, Entry);
            }
            else if (operation == "exp")
            {
                Entry = ScientificFunctions.GenericExponent(PreEntry, Entry);
            }
            else if (operation == "root")
            {
                Entry = ScientificFunctions.GenericRoot(PreEntry, Entry);
            }
            else if (operation == "log")
            {
                Entry = ScientificFunctions.GenericLog(PreEntry, Entry);
            }
            else if (operation == "power")
            {
                Entry = ScientificFunctions.ScientificNotation(Entry);
            }
            else if (operation == "i")
            {
                Entry = StandardFunctions.IntegerDivide(PreEntry, Entry);
            }
            else if (operation == "mod")
            {
                Entry = StandardFunctions.Mod(PreEntry, Entry);
            }

            PreEntry = Entry;

            if (numBase != "dec")
            {
                Entry    = ProgrammerFunctions.ConvertBase(Entry, "dec", numBase);
                PreEntry = ProgrammerFunctions.ConvertBase(PreEntry, "dec", numBase);
            }

            first      = true;
            overwrite  = true;
            operation  = "";
            enteredNum = false;
        }