BN089-BS开发框架MVC4版/source20131023/Zephyr.Net/Zephyr.Utils/Base/Math/ZMath.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Zephyr.Utils
{
public class ZMath
{
public static decimal calcRound(decimal adTargetVal, int anDigits)
{
double dbTargetVal = Convert.ToDouble(adTargetVal);
double decReturn = calcRound(dbTargetVal, anDigits);
return Convert.ToDecimal(decReturn);
}
/// <summary>
/// 四舍五入处理
/// </summary>
/// <param name="adTargetVal">处理对象值</param>
/// <param name="anDigits">处理对象位数(负数时直接去位数)</param>
/// <returns>处理结果数值</returns>
public static double calcRound(double adTargetVal, int anDigits)
{
double dRet = adTargetVal;
try
{
// 先转换成整数再进行计算
dRet = dRet * System.Math.Pow(10, (double)anDigits);
// 四舍五入处理
dRet = dRet + (0.5 * System.Math.Sign(dRet));
if (dRet >= 0)
{
dRet = System.Math.Floor(dRet);
}
else
{
dRet = System.Math.Ceiling(dRet);
}
// 还原回小数
dRet = dRet / System.Math.Pow(10, (double)anDigits);
}
catch
{
dRet = 0;
}
return dRet;
}
/// <summary>
/// 小数上进一处理
/// </summary>
/// <param name="adTargetVal">处理对象值</param>
后面还有 73 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
