Reputation: 1
Im trying to translate an excel function :
10^(-0,2*7^2+2,74*7+(-4,72))
Which gives me the result = 45708,8
When i try to execute this in my application i get the wrong result everytime.. now im stuck at the result = 0
my c# code is:
destB = (decimal)Math.Pow(10, -0.2 * Math.Pow(Decimal.ToDouble(destB), 2.74 * Decimal.ToDouble(destB)+(-4.72)))
Upvotes: 0
Views: 348
Reputation: 12797
What is destB
? The translated version:
Math.Pow(10, -0.2 * 7 * 7 + 2.74 * 7 - 4.72)
If 7
is destB
, then:
Math.Pow(10, -0.2 * destB * destB + 2.74 * destB - 4.72)
Sample code:
double destB = 7;
double result = Math.Pow(10, -0.2 * destB * destB + 2.74 * destB - 4.72);
Console.WriteLine(result);
P.S. I don't do Math.Pow(destB, 2)
since it neither improves readability, neither shortens code.
Upvotes: 1
Reputation: 3259
This would be the exact translation
var destB = Math.Pow(10, -.2 * Math.Pow(7, 2) + 2.74 * 7 + (-4.72));
Upvotes: 0