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


C# ExecutionContext.DivideByZero方法代码示例

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


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

示例1: Quot

        internal override ElaValue Quot(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
                {
                    ctx.NoOverload(left.GetTypeName() + "->" + left.GetTypeName() + "->*", left.GetTypeName() + "->" + right.GetTypeName() + "->*", "quot");
                    return Default();
                }
            }

            var r = right.Ref.AsLong();

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

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

示例2: 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

示例3: Modulus

        internal static ElaValue Modulus(long x, long y, ExecutionContext ctx)
        {
            if (y == 0)
            {
                ctx.DivideByZero(new ElaValue(x));
                return Default();
            }

            var r = x % y;
            return x < 0 && y > 0 || x > 0 && y < 0 ? new ElaValue(r + y) : new ElaValue(r);
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:11,代码来源:LongInstance.cs

示例4: 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


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