I am trying to understand code of some library of one simulation tool that i use.. It has the following line:
propData->fadingStretchingFactor =
(double)(propProfile0->samplingRate) *
propProfile->dopplerFrequency /
propProfile0->baseDopplerFrequency /
(double)SECOND;
Now how do u figure out the orde开发者_如何学Gor of operations if there are two consecutive division operators as in this example
Division is left associative. a / b / c
is equivalent to (a / b) / c
.
Note that C (and C++) do not guarantee any ordering between the evaluations of the terms a
, b
, and c
. For example, foo() / bar()
could call foo()
before bar()
or foo()
after bar()
.
The grouping of operations of equal precedence is determined by operator associativity.
In C++, division is left-associative, which means that the leftmost operation is grouped first, i.e.:
a / b / c
is the same as:
(a / b) / c
Left to right associativity
http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operator_precedence
精彩评论