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!?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…