简体   繁体   中英

Excel formula to C#

Can someone convert this excel formula =1-(POWER(10,LOG(0.8)/12)) to C#?

I've tried with this C# code, but the result is not the same:

1 - (Math.Pow(10, Math.Log(0.8) / 12))

The Excel function LOG is base 10 by default. https://support.office.com/en-us/article/log-function-4e82f196-1ca9-4747-8fb0-6c4a3abb3280

The .NET Math.Log() function is base e by default. https://docs.microsoft.com/en-us/dotnet/api/system.math.log?view=netframework-4.7.2

You have to change Math.Log(0.8) to Math.Log10(0.8) like this.

1 - (Math.Pow(10, Math.Log10(0.8) / 12))

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