【发布时间】:2018-10-11 13:03:45
【问题描述】:
有人可以将此 excel 公式 =1-(POWER(10,LOG(0.8)/12)) 转换为 C# 吗?
我尝试过使用这段 C# 代码,但结果不一样:
1 - (Math.Pow(10, Math.Log(0.8) / 12))
【问题讨论】:
标签: c# excel excel-formula formula
有人可以将此 excel 公式 =1-(POWER(10,LOG(0.8)/12)) 转换为 C# 吗?
我尝试过使用这段 C# 代码,但结果不一样:
1 - (Math.Pow(10, Math.Log(0.8) / 12))
【问题讨论】:
标签: c# excel excel-formula formula
Excel 函数 LOG 默认以 10 为底。 https://support.office.com/en-us/article/log-function-4e82f196-1ca9-4747-8fb0-6c4a3abb3280
.NET Math.Log() 函数默认是基于 e 的。 https://docs.microsoft.com/en-us/dotnet/api/system.math.log?view=netframework-4.7.2
您必须像这样将Math.Log(0.8) 更改为Math.Log10(0.8)。
1 - (Math.Pow(10, Math.Log10(0.8) / 12))
【讨论】: