本文整理汇总了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());
}
示例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());
}
示例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);
}
示例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);
}