a very very beginner question

Jun 25, 2011 at 1:47pm
Greetings,

I have a very very beginner question. I am terying to understand a code and sometimes I doubt about a beginner point !!!

1
2
3
edepSum *=x;
edepSum2 *= x;
edepSum2 -= edepSum*edepSum;


The 1st line says that the previous value of edepSum is multiplied by x and the new value is stored in edepSum.

The second one implies the same thing.

The third line implies that the previous value of edepSum2 is subtracted from edepSum*edepSum and the subtraction result is stored in edepSum2.

Could you please tell me if I am in the right track ???

Thank you in advance
Jun 25, 2011 at 1:52pm
You are correct, that's exactly what that code does. Except, as Xander pointed out, you have the third part backwards. It subtracts edepSum*edepSum from the original value of edepSum2.
                                                                     I can't believe I didn't see that, thanks, Xander314.
Last edited on Jun 25, 2011 at 2:02pm
Jun 25, 2011 at 1:55pm
closed account (iLUjLyTq)
The syntax you posted is equvialent to:
1
2
3
edepSum = edepSum * x;
edepSum2 = edepSum2 * x;
edepSum2 = edepSum2 - edepSum * edepSum;


So yes, you are right.

edit: Xander314 is right, fixed my syntax
Last edited on Jun 25, 2011 at 2:00pm
Jun 25, 2011 at 1:57pm
The third line implies that the previous value of edepSum2 is subtracted from edepSum*edepSum and the subtraction result is stored in edepSum2.

Surely it should be "the value of edepSum*edepSum is subtracted from the previous value of edepSum2 and the subtraction result is stored in edebSum2", and not the other way round. Perhaps this was just a typo?
Topic archived. No new replies allowed.