예제 #1
0
        public DyObject Sqrt(ExecutionContext ctx, DyObject n)
        {
            if (n.TypeId != DyType.Float && n.TypeId != DyType.Integer)
            {
                return(ctx.InvalidType(n));
            }

            return(new DyFloat(Math.Sqrt(n.GetFloat())));
        }
예제 #2
0
        public DyObject Round(ExecutionContext ctx, DyObject number, [Default(2)] DyObject digits)
        {
            if (number.TypeId != DyType.Float)
            {
                ctx.InvalidType(number);
            }
            else if (digits.TypeId != DyType.Integer)
            {
                ctx.InvalidType(digits);
            }

            return(new DyFloat(Math.Round(number.GetFloat(), (int)digits.GetInteger())));
        }