Reputation: 63
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))
Upvotes: 0
Views: 306
Reputation: 1265
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://learn.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))
Upvotes: 3