This might be a stupid question, but what does *= operator do?
I have these two statements in the code:
double NoverL = N/L;
NoverL *= 1.0-Mratio(2)-Mratio(3);
It's just multiplication in this case. The same as writing:
NoverL = NoverL * (1.0-Mratio(2)-Mratio(3));
It's a compact way of modifying the variable on the left of the operator, then assigning the result to it. These examples all do the same thing:
With long variable names it's useful:
longVariableNameHere = longVariableNameHere * b;
longVariableNameHere *= b;
The resulting code might
be more efficient too, though modern compilers should optimise the code so it makes little or no difference.
The same style applies to other operations combined with = too.
Topic archived. No new replies allowed.