Example #1
0
        public int SimplifyInt(string equation, RoundingMethods roundMethod)
        {
            SimplificationReturnValue retval = Simplify(equation);

            if (retval.ReturnType == SimplificationReturnValue.ReturnTypes.Integer)
            {
                return(retval.IntValue);
            }

            if (roundMethod == RoundingMethods.RoundDown)
            {
                return((int)Math.Floor(retval.DoubleValue));
            }
            if (roundMethod == RoundingMethods.RoundUp)
            {
                return((int)Math.Ceiling(retval.DoubleValue));
            }
            if (roundMethod == RoundingMethods.Round)
            {
                return((int)Math.Round(retval.DoubleValue));
            }

            return((int)Math.Truncate(retval.DoubleValue));
        }
Example #2
0
        public int SimplifyInt(string equation, RoundingMethods roundMethod)
        {
            SimplificationReturnValue retval = Simplify(equation);

            if (retval.ReturnType == SimplificationReturnValue.ReturnTypes.Integer)
                return retval.IntValue;

            if (roundMethod == RoundingMethods.RoundDown)
                return (int)Math.Floor(retval.DoubleValue);
            if (roundMethod == RoundingMethods.RoundUp)
                return (int)Math.Ceiling(retval.DoubleValue);
            if (roundMethod == RoundingMethods.Round)
                return (int)Math.Round(retval.DoubleValue);

            return (int)Math.Truncate(retval.DoubleValue);
        }