0

Forgive me if this is already on here somewhere but I couldn't find it.

SO, I am doing a simple calculation.

double radius = 2.50;
//double pi = Math.PI;

//double areaOfCircle;

double radSquared = radius * radius;

double radiusSquared = Math.Pow(radius, radius); //This, to me, give the wrong answer..?

//areaOfCircle = Math.PI * radSquared; //This one give the correct calculation

Why, if I just do radius * radius do I get an accurate calculation, but when I use the Math.Pow method, I get a completely different answer...?

Surely it is doing the exact same calculation? What am I missing?

1 Answers1

2

Read the documentation.

You are raising radius to the power of radius, not radius to the power of 2.

harrymc
  • 480,290