/// <summary>
/// 特殊四舍五入,
/// 1.1; 1.2; 1.3; 1.4; 1.5 结果1.5
/// 1.6; 1.7; 1.8; 1.9; 2.0 结果2.0
/// </summary>
/// <param name="f"></param>
/// <returns></returns>
public static double TransmitNum(double f)
{
if ((f - (int)f) <= 0.5 && (f - (int)f > 0))
return (int)f + 0.5;
if ((f - (int)f) > 0.5)
return (int)f + 1.0;
if ((f - (int)f) == 0)
return f;
return f;
}
C#各种小数四舍五入汇总
最新推荐文章于 2024-07-11 22:26:33 发布