🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.misc
Article #2885

Re: int / int ?

#2885
From: Will Rose
Date: Sun, 29 Nov 1998 00:00
27 lines
2087 bytes
Chris Marriott (chris@NOSPAM.skymap.com) wrote:

: Will Rose wrote in message <912351722.217465@optional.cts.com>...
: >The operations * and / are both left-associative, so 5 * 3 / 2 comes
: >to 7, and 5 / 2 * 3 comes to 6.

: If you don't use parentheses to force the order of evaluation, does the C
: language guarentee left-to-right evaluation? I don't have a copy of the
: language reference at hand to check.

You rapidly step off into deep water here, and I don't trust myself to
get the technical terms right.  Precedence and associativity go togther
to determine how an expression is evaluated; left-to-right evaluation
is another thing altogether, and in fact cannot, with the exception
of '&&', '||', "?:', and ',' be relied on.  The C faq, section 3.8,
has a number of practical suggestions on how to avoid pushing your
luck in this area.

Probably the best simple summary is in K&R, but for the full story
you probably need the syntax rules of the standard, which express
the precedence and associativity rules mentioned above.  ISTR this
was discussed about a year ago, and either Lawrence Kirby or Chris
Torek gave a much better explanation that I can; try Dejanews.


Will
cwr@crash.cts.com
Technical Details
Message-ID: <912362255.713357@optional.cts.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <366155E6.632A909D@erols.com> <912351722.217465@optional.cts.com> <912357376.6545.0.nnrp-03.9e9809e7@news.demon.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f8d38,7450d421b142666f
X-Google-Attributes: gidf8d38,public
X-Google-Thread: 1014db,7450d421b142666f
X-Google-Attributes: gid1014db,public
X-Google-Thread: 105df1,7450d421b142666f
X-Google-Attributes: gid105df1,public
From: cwr@cts.com (Will Rose)
Subject: Re: int / int ?
Date: 1998/11/29
Message-ID: <912362255.713357@optional.cts.com>
X-Deja-AN: 416818521
Cache-Post-Path: optional.cts.com!cwr@crash-i2.cts.com
References: <366155E6.632A909D@erols.com> <912351722.217465@optional.cts.com> <912357376.6545.0.nnrp-03.9e9809e7@news.demon.co.uk>
Organization: CTS Network Services (CTSNET), San Diego, CA
Followup-To: comp.os.ms-windows.programmer.misc,borland.public.cpp.language,comp.lang.c
Newsgroups: comp.os.ms-windows.programmer.misc,borland.public.cpp.language,comp.lang.c