本文整理汇总了C#中Constant.ToReal64方法的典型用法代码示例。如果您正苦于以下问题:C# Constant.ToReal64方法的具体用法?C# Constant.ToReal64怎么用?C# Constant.ToReal64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constant
的用法示例。
在下文中一共展示了Constant.ToReal64方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FormatValue
public static string FormatValue(Constant c)
{
var pt = (PrimitiveType)c.DataType;
if (pt.Domain == Domain.SignedInt)
{
return FormatSignedValue(c);
}
else if (pt.Domain == Domain.Real)
{
return c.ToReal64().ToString("G");
}
else
return FormatUnsignedValue(c);
}
示例2: FormatValue
public static string FormatValue(Constant c)
{
var pt = (PrimitiveType)c.DataType;
if (pt.Domain == Domain.SignedInt)
{
return FormatSignedValue(c);
}
else if (pt.Domain == Domain.Real)
{
var str = c.ToReal64().ToString("G", CultureInfo.InvariantCulture);
if (str.IndexOfAny (floatSpecials) < 0)
{
str = str + ".0";
}
return str;
}
else
return FormatUnsignedValue(c);
}
示例3: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
return BuildConstant(c1.DataType, c2.DataType, c1.ToReal64() + c2.ToReal64());
}
示例4: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
if (!ValidArgs(c1, c2))
return Constant.Invalid;
return BuildConstant(c1.DataType, c2.DataType, c1.ToReal64() * c2.ToReal64());
}
示例5: ApplyConstants
public override Constant ApplyConstants(Constant c1, Constant c2)
{
if (!ValidArgs(c1, c2))
return Constant.Invalid;
return Constant.Bool(c1.ToReal64() <= c2.ToReal64());
}
示例6: VisitConstant
public virtual void VisitConstant(Constant c)
{
if (!c.IsValid)
{
writer.Write("<invalid>");
return;
}
var pt = c.DataType.ResolveAs<PrimitiveType>();
if (pt != null)
{
if (pt.Domain == Domain.Boolean)
{
writer.Write(Convert.ToBoolean(c.GetValue()) ? "true" : "false");
}
else if (pt.Domain == Domain.Real)
{
string sr;
if (pt.Size == 4)
{
sr = c.ToFloat().ToString("g", CultureInfo.InvariantCulture);
}
else
{
sr = c.ToReal64().ToString("g", CultureInfo.InvariantCulture);
}
if (sr.IndexOfAny(nosuffixRequired) < 0)
{
sr += ".0";
}
if (pt.Size == 4)
{
sr += "F";
}
writer.Write(sr);
}
else
{
object v = c.GetValue();
writer.Write(FormatString(pt, v), v);
}
return;
}
StringConstant s = c as StringConstant;
if (s != null)
{
writer.Write("{0}{1}{0}", '"', s.GetValue());
}
}