简体   繁体   English

是否有与Delphi的System.Frac等效的方法?

[英]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);
}

try this link 试试这个链接

 double value, fraction;
 value = 8.24;
 fraction = value - (int) value;

OR 要么

Decimal d=1.58M;
Decimal fractional=d-Decimal.Truncate(d);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM