Well obviously I'm doing something wrong but I'm stuck so I hope you will be able to help me out.
I have this equation in Excel: =((247*(145/174)^3*60)/3600)*100
Result = 238.233
And I have tried this in .Net:
(Math.Pow(247.0 * (145.0 / 174.0), Convert.ToDouble(3*60)) / 3600.0) * 100;
The problem is that C# returns a INF instead of the result and if I try to do this:
((long)Math.Pow(247.0 * (145.0 / 174.0), Convert.ToDouble(3*60)) / 3600.0) * 100;
The result does not match Excel.
I suspect you should write as below:
247.0*Math.Pow(145.0/174.0,3)*60/3600*100;
See the fiddle here: http://dotnetfiddle.net/B32N3B
this is because in excel operator ^
( rise to power ) has precedence against to *
so the intent of the excel line is to rise to 3
then multiply for 60
, not rise to 3*60
, that of course land to an overflow.
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.