[Solved] Math-pow incorrect results


Your question is very unclear; in the future, you’ll probably get better results if you post a clear question with a code sample that actually compiles and demonstrates the problem you’re actually having. Don’t make people guess what the problem is.

If what you want to do is display a double-precision floating point number without the scientific notation then use the standard number formatting specifier:

Console.WriteLine(string.Format("{0:N}", Math.Pow(10, 100)));

Results in:

10,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.00

If what you have a problem with is that the result is rounded off, then don’t use double-precision floats; they are accurate to only 15 decimal places. Try doing your arithmetic in BigIntegers, which have arbitrary integer precision.

7

solved Math-pow incorrect results