예제 #1
0
            public override object CallLateBound(object thisObject, params object[] argumentValues)
            {
                var number = TypeConverter.ToNumber(thisObject);

                //No precision specified
                if (argumentValues.Length == 0 || argumentValues[0] == Undefined.Value || argumentValues[0] == Null.Value || argumentValues[0] == null)
                {
                    return(MathObject.Floor(number));
                }

                var precision = TypeConverter.ToNumber(argumentValues[0]);

                var multiplier = Math.Pow(10, Math.Abs(precision));

                if (precision < 0)
                {
                    multiplier = 1 / multiplier;
                }
                return(MathObject.Floor(number * multiplier) / multiplier);
            }