Пример #1
0
        public IOperand Power(IOperand rhs)
        {
            if (!(rhs is LongOperand))
            {
                throw new RPN_Exception("Argument invalid in LongOperand.Power : rhs");
            }
            LongOperand oprResult = new LongOperand("Result", Type.GetType("System.Int64"));

            oprResult.Value = Math.Pow((long)this.Value, (long)((Operand)rhs).Value);
            return(oprResult);
        }
Пример #2
0
        public IOperand Modulo(IOperand rhs)
        {
            if (!(rhs is LongOperand))
            {
                throw new RPN_Exception("Argument invalid in LongOperand.Modulo : rhs");
            }
            LongOperand oprResult = new LongOperand("Result", Type.GetType("System.Int64"));

            oprResult.Value = (long)this.Value % (long)((Operand)rhs).Value;
            return(oprResult);
        }
Пример #3
0
        /// <summary>
        /// Factory method to create corresponding Operands.
        /// Extended this method to create newer datatypes.
        /// </summary>
        /// <param name="szVarName"></param>
        /// <param name="varType"></param>
        /// <param name="varValue"></param>
        /// <returns></returns>
        static public Operand CreateOperand(string szVarName, Type varType, object varValue)
        {
            Operand oprResult = null;

            switch (varType.ToString())
            {
            case "System.Int32":
            case "System.Int64":
                oprResult = new LongOperand(szVarName, varValue);
                return(oprResult);

            case "System.Double":
                oprResult = new DoubleOperand(szVarName, varValue);
                return(oprResult);
                //case System.Decimal:
                //case System.Single:
                //	oprResult = new DecimalOperand( szVarName, varValue );
                //	return oprResult;
                //	break;
            }
            throw new RPN_Exception("Unhandled type : " + varType.ToString());
        }