当前位置: 首页>>代码示例>>C#>>正文


C# ElaValue.DirectGetSingle方法代码示例

本文整理汇总了C#中ElaValue.DirectGetSingle方法的典型用法代码示例。如果您正苦于以下问题:C# ElaValue.DirectGetSingle方法的具体用法?C# ElaValue.DirectGetSingle怎么用?C# ElaValue.DirectGetSingle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ElaValue的用法示例。


在下文中一共展示了ElaValue.DirectGetSingle方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Divide

        internal override ElaValue Divide(ElaValue left, ElaValue right, ExecutionContext ctx)
        {
            if (right.TypeId != ElaMachine.REA)
            {
                if (right.TypeId == ElaMachine.DBL)
                    return new ElaValue(left.DirectGetSingle() / right.Ref.AsDouble());
                else if (right.TypeId == ElaMachine.INT)
                    return new ElaValue(left.DirectGetSingle() / right.I4);
                else if (right.TypeId == ElaMachine.LNG)
                    return new ElaValue(left.DirectGetSingle() / right.Ref.AsLong());
                else
                {
                    NoOverloadBinary(TCF.SINGLE, right, "divide", ctx);
                    return Default();
                }
            }

            if (right.DirectGetSingle() == 0)
            {
                ctx.DivideByZero(left);
                return Default();
            }

            return new ElaValue(left.DirectGetSingle() / right.DirectGetSingle());
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:25,代码来源:SingleInstance.cs

示例2: Equal

        internal override bool Equal(ElaValue left, ElaValue right, ExecutionContext ctx)
        {
            if (right.TypeId != ElaMachine.REA)
            {
                if (right.TypeId == ElaMachine.DBL)
                    return left.DirectGetSingle() == right.Ref.AsDouble();
                else if (right.TypeId == ElaMachine.INT)
                    return left.DirectGetSingle() == right.I4;
                else if (right.TypeId == ElaMachine.LNG)
                    return left.DirectGetSingle() == right.Ref.AsLong();
                else
                {
                    NoOverloadBinary(TCF.SINGLE, right, "equal", ctx);
                    return false;
                }
            }

            return left.DirectGetSingle() == right.DirectGetSingle();
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:19,代码来源:SingleInstance.cs

示例3: Add

        internal override ElaValue Add(ElaValue left, ElaValue right, ExecutionContext ctx)
        {
            if (right.TypeId != ElaMachine.LNG)
            {
                if (right.TypeId == ElaMachine.INT)
                    return new ElaValue(left.Ref.AsLong() + right.I4);
                else if (right.TypeId == ElaMachine.REA)
                    return new ElaValue(left.Ref.AsLong() + right.DirectGetSingle());
                else if (right.TypeId == ElaMachine.DBL)
                    return new ElaValue(left.Ref.AsLong() + right.Ref.AsDouble());
                else
                {
                    NoOverloadBinary(TCF.LONG, right, "add", ctx);
                    return Default();
                }
            }

            return new ElaValue(left.Ref.AsLong() + right.Ref.AsLong());
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:19,代码来源:LongInstance.cs

示例4: Divide

        internal override ElaValue Divide(ElaValue left, ElaValue right, ExecutionContext ctx)
        {
            if (right.TypeId != ElaMachine.LNG)
            {
                if (right.TypeId == ElaMachine.INT)
                {
                    return new ElaValue((Double)left.Ref.AsLong() / right.I4);
                }
                else if (right.TypeId == ElaMachine.REA)
                    return new ElaValue(left.Ref.AsLong() / right.DirectGetSingle());
                else if (right.TypeId == ElaMachine.DBL)
                    return new ElaValue(left.Ref.AsLong() / right.Ref.AsDouble());
                else
                {
                    NoOverloadBinary(TCF.INT, right, "divide", ctx);
                    return Default();
                }
            }

            var r = right.Ref.AsLong();
            return new ElaValue((Double)left.Ref.AsLong() / r);
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:22,代码来源:LongInstance.cs

示例5: Remainder

        internal override ElaValue Remainder(ElaValue left, ElaValue right, ExecutionContext ctx)
        {
            if (right.TypeId != ElaMachine.LNG)
            {
                if (right.TypeId == ElaMachine.INT)
                {
                    if (right.I4 == 0)
                    {
                        ctx.DivideByZero(left);
                        return Default();
                    }

                    return new ElaValue(left.Ref.AsLong() % right.I4);
                }
                else if (right.TypeId == ElaMachine.REA)
                    return new ElaValue(left.Ref.AsLong() % right.DirectGetSingle());
                else if (right.TypeId == ElaMachine.DBL)
                    return new ElaValue(left.Ref.AsLong() % right.Ref.AsDouble());
                else
                {
                    NoOverloadBinary(TCF.LONG, right, "remainder", ctx);
                    return Default();
                }
            }

            var rl = right.Ref.AsLong();

            if (rl == 0)
            {
                ctx.DivideByZero(left);
                return Default();
            }

            return new ElaValue(left.Ref.AsLong() % rl);
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:35,代码来源:LongInstance.cs

示例6: Power

        internal override ElaValue Power(ElaValue left, ElaValue right, ExecutionContext ctx)
        {
            if (right.TypeId != ElaMachine.LNG)
            {
                if (right.TypeId == ElaMachine.INT)
                    return new ElaValue((Int64)Math.Pow(left.Ref.AsLong(), right.I4));
                else if (right.TypeId == ElaMachine.REA)
                    return new ElaValue((Single)Math.Pow(left.Ref.AsLong(), right.DirectGetSingle()));
                else if (right.TypeId == ElaMachine.DBL)
                    return new ElaValue((Double)Math.Pow(left.Ref.AsLong(), right.Ref.AsDouble()));
                else
                {
                    NoOverloadBinary(TCF.LONG, right, "power", ctx);
                    return Default();
                }
            }

            return new ElaValue((Int64)Math.Pow(left.Ref.AsLong(), right.Ref.AsLong()));
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:19,代码来源:LongInstance.cs

示例7: Modulus

        internal override ElaValue Modulus(ElaValue left, ElaValue right, ExecutionContext ctx)
        {
            if (right.TypeId != ElaMachine.LNG)
            {
                if (right.TypeId == ElaMachine.INT)
                    return Modulus(left.Ref.AsLong(), right.I4, ctx);
                else if (right.TypeId == ElaMachine.REA)
                    return SingleInstance.Modulus(left.Ref.AsLong(), right.DirectGetSingle(), ctx);
                else if (right.TypeId == ElaMachine.DBL)
                    return DoubleInstance.Modulus(left.Ref.AsLong(), right.Ref.AsDouble(), ctx);
                else
                {
                    NoOverloadBinary(TCF.LONG, right, "modulus", ctx);
                    return Default();
                }
            }

            return Modulus(left.Ref.AsLong(), right.Ref.AsLong(), ctx);
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:19,代码来源:LongInstance.cs

示例8: Lesser

        internal override bool Lesser(ElaValue left, ElaValue right, ExecutionContext ctx)
        {
            if (right.TypeId != ElaMachine.LNG)
            {
                if (right.TypeId == ElaMachine.INT)
                    return left.Ref.AsLong() < right.I4;
                else if (right.TypeId == ElaMachine.REA)
                    return left.Ref.AsLong() < right.DirectGetSingle();
                else if (right.TypeId == ElaMachine.DBL)
                    return left.Ref.AsLong() < right.Ref.AsDouble();
                else
                {
                    NoOverloadBinary(TCF.LONG, right, "lesser", ctx);
                    return false;
                }
            }

            return left.Ref.AsLong() < right.Ref.AsLong();
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:19,代码来源:LongInstance.cs

示例9: Show

        internal override string Show(ElaValue value, ExecutionContext ctx)
        {
            var d = value.DirectGetSingle();

            if (Single.IsInfinity(d) || Single.IsNaN(d))
                return value.ToString();
            else
                return value.ToString() + "f";
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:9,代码来源:SingleInstance.cs

示例10: Negate

 internal override ElaValue Negate(ElaValue value, ExecutionContext ctx)
 {
     return new ElaValue(-value.DirectGetSingle());
 }
开发者ID:rizwan3d,项目名称:elalang,代码行数:4,代码来源:SingleInstance.cs


注:本文中的ElaValue.DirectGetSingle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。