Exemple #1
0
        public static PValue RunStatically(PValue arg0, StackContext sctx)
        {
            var x = (double) arg0.ConvertTo(sctx, PType.Real, true).Value;

            return System.Math.Tan(x);
        }
Exemple #2
0
        public static PValue RunStatically(PValue arg, StackContext sctx)
        {
            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (arg == null)
                throw new ArgumentNullException("arg");

            if (arg.Type == PType.Int)
            {
                var x = (int) arg.Value;

                return System.Math.Abs(x);
            }
            else
            {
                var x = (double) arg.ConvertTo(sctx, PType.Real, true).Value;

                return System.Math.Abs(x);
            }
        }
Exemple #3
0
 private static EntityRef _getMacroRef(StackContext sctx, PValue rawMacro)
 {
     PFunction func;
     MacroCommand mcmd;
     if (rawMacro.TryConvertTo(sctx, out func))
         return EntityRef.Function.Create(func.Id, func.ParentApplication.Module.Name);
     else if (rawMacro.TryConvertTo(sctx, out mcmd))
         return EntityRef.MacroCommand.Create(mcmd.Id);
     else
         return rawMacro.ConvertTo<EntityRef>(sctx);
 }
Exemple #4
0
        public static PValue RunStatically(PValue arg0, PValue arg1, StackContext sctx)
        {
            if (arg0.Type == PType.Int && arg1.Type == PType.Int)
            {
                var a = (int) arg0.Value;
                var b = (int) arg1.Value;

                return System.Math.Max(a, b);
            }
            else
            {
                var a = (double) arg0.ConvertTo(sctx, PType.Real, true).Value;
                var b = (double) arg1.ConvertTo(sctx, PType.Real, true).Value;

                return System.Math.Max(a, b);
            }
        }
Exemple #5
0
        public static PValue RunStatically(PValue arg0, PValue arg1, StackContext sctx)
        {
            var x = (double) arg0.ConvertTo(sctx, PType.Real, true).Value;

            int d;
            PValue pd;

            if (arg1 != null && arg1.TryConvertTo(sctx, PType.Int, true, out pd))
                d = System.Math.Abs((int) pd.Value);
            else
                d = 0;

            return System.Math.Round(x, d, MidpointRounding.AwayFromZero);
        }