parenthesis

I

Irrwahn Grausewitz

P.J. Plauger said:
If a compiler generates incorrect code, why should one bother to write
correct code at all, as it is rendered useless by the (flawed)
implementation?

And your point is...?

That /is/ the point. The OP asked if he can rely upon a certain order
of evaluation for a given parenthesized expression. He was then told:
"Yes, from the programmers POV, in the sense that there is this as-if
rule." And if it wouldn't be that way, using parentheses in
expressions to /change/ the order of evaluation would be rather
pointless. No more, no less.

Regards
 
M

Micah Cowan

Arthur J. O'Dwyer said:
(s/were/would be/ in both this and the snipped part, BTW.
And s/paran/paren/ .)

Actually, the above (with "were") is AFAICT correct, just
something I usually see in somewhat older English usage.

-Micah
 
R

Richard Bos

So, is x=a+b+c+d; considered treated the same as x=((a+b)+c)+d; i.e.,
the summation is carried out from left to right?

Yes; _except_ where the implementation can guarantee that the result
will be the same if it does this another way. For floating point
variables, this will be rare; for integral variables, it is, in fact,
the usual case.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,091
Messages
2,570,604
Members
47,223
Latest member
smithjens316

Latest Threads

Top