丸め:
Convert.ToDecimal(1.66666.ToString( "F" + decimalCount))
切り上げられません。
パブリック静的小数CutDecimalWithN(小数点D、int型N)
{
ストリングstrDecimal = d.ToString()。
int型のインデックス= strDecimal.IndexOf( "");
IF(インデックス== -1 || strDecimal.Length <指数+ N + 1)
{
strDecimal = String.Formatの( "{0:F" + N + "}"、D)。
}
他
{
int型の長さ=指数;
IF(N!= 0)
{
長さ=指数+ N + 1。
}
strDecimal = strDecimal.Substring(0、長さ)。
}
Decimal.Parse(strDecimal)を返します。
}