Пример #1
0
        public override ValueEval Evaluate(int srcCellRow, int srcCellCol, ValueEval arg0)
        {
            double d;

            try
            {
                ValueEval ve = OperandResolver.GetSingleValue(arg0, srcCellRow, srcCellCol);
                if (ve is BlankEval)
                {
                    return(NumberEval.ZERO);
                }
                if (ve is StringEval)
                {
                    // Note - asymmetric with UnaryMinus
                    // -"hello" Evaluates to #VALUE!
                    // but +"hello" Evaluates to "hello"
                    return(ve);
                }
                d = OperandResolver.CoerceValueToDouble(ve);
            }
            catch (EvaluationException e)
            {
                return(e.GetErrorEval());
            }
            return(new NumberEval(+d));
        }
Пример #2
0
        public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0)
        {
            double d;

            try
            {
                ValueEval ve = OperandResolver.GetSingleValue(arg0, srcRowIndex, srcColumnIndex);
                d = OperandResolver.CoerceValueToDouble(ve);
            }
            catch (EvaluationException e)
            {
                return(e.GetErrorEval());
            }
            if (d == 0.0)
            { // this '==' matches +0.0 and -0.0
                return(NumberEval.ZERO);
            }
            return(new NumberEval(-d));
        }
        //public int Type
        //{
        //    get
        //    {
        //        // TODO - remove
        //        throw new Exception("obsolete code should not be called");
        //    }
        //}
        protected double SingleOperandEvaluate(ValueEval arg, int srcCellRow, int srcCellCol)
        {
            ValueEval ve = OperandResolver.GetSingleValue(arg, srcCellRow, srcCellCol);

            return(OperandResolver.CoerceValueToDouble(ve));
        }