Sujet : Re: while(T[l]<p & l<=r)
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 28. Mar 2024, 12:37:39
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uu3kqb$3i23g$1@dont-email.me>
References : 1
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 27.03.2024 12:35, fir wrote:
tell me, is while(T[l]<p & l<=r) the same as while((T[l]<p)&&(l<=r))
1. As long as K&R precedences still hold you don't need the inner
parentheses; '<' and '<=' has higher precedence than '&' and '&&'.
2. In this case where you compare predicate expressions that
evaluate to '0' and '1' on both sides of '&' and '&&' respectively
these expressions are (while not the same) equivalent _here_. If
you don't want to operate on bits but want to express a boolean
conjunction you should use '&&', though.
i was unable ro remember that
You could look that up if you cannot remember that. Wikipedia[*]
has a page with a lot information, and a concise list you can,
for example, find here:
https://www.cs.uic.edu/~i109/Notes/COperatorPrecedenceTable.pdfJanis
[*]
https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B