And no, this does not (to my understanding) involve integer division or floating-point rounding issues.
My exact code is:
static void Main(string[] args)
{
double power = (double)1.0 / (double)7.0;
double expBase = -128.0;
System.Console.WriteLine("sanity check: expected: -128 ^ 0.142857142857143 = -2. actual: " + expBase + " ^ " + power + " = " + Math.Pow(expBase, power));
System.Console.ReadLine();
}
The output is:
sanity check: expected: -128 ^ 0.142857142857143 = -2. actual: -128 ^ 0.14285
7142857143 = NaN
The Target Framework for this code is (according to solution properties) .NET Framework 4.0 Client Profile.
Strangely I haven't found any mention of this anywhere on the Web. Am I taking crazy pills here!?
Seems to be exactly as specified; from the Math.Pow() remarks section on Pow(x,y)
;
Parameters
x < 0 but not NegativeInfinity; y is not an integer, NegativeInfinity, or PositiveInfinity.Result
NaN