本文整理汇总了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());
}
示例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();
}
示例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());
}
示例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);
}
示例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);
}
示例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()));
}
示例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);
}
示例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();
}
示例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";
}
示例10: Negate
internal override ElaValue Negate(ElaValue value, ExecutionContext ctx)
{
return new ElaValue(-value.DirectGetSingle());
}