| Liste des Groupes | Revenir à cl c |
On 2026-05-31 07:18, David Brown wrote:The parentheses do not dictate the order of evaluation. But you are correct - and it's worth pointing out, so thank you for doing that - that for floating point operations, the grouping of operations can affect the result.On 31/05/2026 12:10, Bart wrote:...On 31/05/2026 10:49, David Brown wrote:On 31/05/2026 10:12, Richard Harnden wrote:On 31/05/2026 00:43, Keith Thompson wrote:But you might consider "(a + b) + c" to be "parsed differently" than "a(a + b) + c mandates adding a to b, then adding the result to c. a + (b
+ (b + c)", because of how a particular compiler implements its parser.
It's possible that this results in different code for a particular
compiler, but there is no difference in the meaning for the C language.
+ c) mandates adding b to c then adding the result to a. As far as
mathematics is concerned, that's the same thing, but in computer math it
can make a difference if one of the two results in overflow or
unnecessary loss of precision, and the other does not.
...You're correct with regard to the function calls, but the parenthesizedDo you have>
an example where they make no difference but people might think they do?
>
People might think they affect the order of evaluation, such as when you
have function calls :
>
u = foo(x) + (foo(y) + foo(z));
>
Some people might think the use of parentheses means that "foo(y)" and
"foo(z)" are called before "foo(x)", when the order of all these calls
(and the additions) is unspecified. (Again, a given compiler might be
influenced by the parentheses, but the language does not require it.
addition must be performed first, and the other one second, which may
make a difference, for the same reasons given in my previous paragraph.
Les messages affichés proviennent d'usenet.