[英]Is there an equivalent method to Delphi's System.Frac?
I am looking for a method equivalent to Delphi's System.Frac
in .NET. 我正在寻找一种等效于.NET中Delphi的
System.Frac
的方法。
The Delphi function strips the whole number leaving just the value after the decimal point. Delphi函数剥离整数,只保留小数点后的值。
I could write my own method but thought I would check? 我可以编写自己的方法,但以为我会检查?
I know of no such function, and I don't think it exists. 我不知道这种功能,而且我认为它不存在。 Such a function would be part of the
Math
class, and I can't see it there. 这样的函数将是
Math
类的一部分,我在那里看不到。 So you'll have to go with value-Math.Truncate(value)
: 因此,您必须使用
value-Math.Truncate(value)
:
public static double Frac(double value)
{
return value-Math.Truncate(value);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.