简体   繁体   中英

Is there an equivalent method to Delphi's System.Frac?

I am looking for a method equivalent to Delphi's System.Frac in .NET.

The Delphi function strips the whole number leaving just the value after the decimal point.

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. So you'll have to go with 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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