Calculate power of a negative number

后端 未结 3 706
清酒与你
清酒与你 2021-01-23 03:23

I relatively new to C# and since Math.Pow(x,y) returns NaN for a negative number(read: not negative power), I want to know how to calculate result more efficiently. What I am do

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-23 03:44

    I think you can use System.Numerics.Complex that can calculate Imaginary.

    See:https://msdn.microsoft.com/en-us/library/system.numerics.complex%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

    http://www.extremeoptimization.com/QuickStart/CSharp/ComplexNumbers.aspx

    https://www.codeproject.com/Tips/3370/Complex-Math-Library-for-Csharp-and-VB-NET

提交回复
热议问题