0

Hi,

I am having some problems at times with converting to double and taking the square root.

Sometimes it works and sometimes it does not and I am not sure why!

I am adding the sum of the square root of 10 numbers for each of 50 rows into an array.

Then I am adding all the sum of the 50 rows into a variable.

It seems to only work when I add the sum of the 10 numbers and then take the square root of the sum for each of the 50 rows, but when I try to add the sum of the square root of 10 numbers for each of the 50 rows I get the wrong results???

Can anyone help?

Here is my code:

```
for (liAddRowPos= 1; liAddRowPos <= 50; liAddRowPos++)
{
aGV.gaElementSymmetry_Sum[liAddRowPos, 1] = 0;
aGV.gaElementSymmetry_Sum_SQRT[liAddRowPos, 1] = 0.0;
for (liMiscLp = 1; liMiscLp <= 10; liMiscLp++) aGV.gaElementSymmetry_Sum[liAddRowPos, 1] += aGV.gaElementSymmetry[liAddRowPos, liMiscLp];
for (liMiscLp = 1; liMiscLp <= 10; liMiscLp++) aGV.gaElementSymmetry_Sum_SQRT[liAddRowPos, 1] += Convert.ToDouble(Math.Sqrt(aGV.gaElementSymmetry[liAddRowPos, liMiscLp]));
}
aGV.giGrandTotal = 0.0;
aGV.giGrandTotal_SQRT = 0.0;
for (liAddRowPos= 1; liAddRowPos <= 50; liAddRowPos++)
{
aGV.giGrandTotal += Convert.ToDouble(Math.Sqrt(aGV.gaElementSymmetry_Sum[liAddRowPos, 1]));
aGV.giGrandTotal_SQRT += Convert.ToDouble(Math.Sqrt(aGV.gaElementSymmetry_Sum_SQRT[liAddRowPos, 1]));
}
```

An answer would be greatly appreciated.

Thanks

Roy