Article View: comp.os.ms-windows.programmer.misc
Article #2890Re: int / int ?
From: Lawrence Kirby
Date: Mon, 30 Nov 1998 00:00
Date: Mon, 30 Nov 1998 00:00
56 lines
2586 bytes
2586 bytes
In article <912408515.26096.1.nnrp-07.9e9809e7@news.demon.co.uk>
chris@NOSPAM.skymap.com "Chris Marriott" writes:
>
>Tony Street wrote in message <36618e67.0@isc-newsserver.isc.rit.edu>...
>>Chris Marriott wrote in message
>>>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.
>>
>>Yes..... the C language will follow all precedence rules, all the time..
>
>
>We're not talking here about precedence, Tony. "*" and "/" have the SAME
>precedence.
"Precedence rules" are often taken to include associativity as well. Binary
* and / are left associative which means that a subexpression that appears
between two of these will be bound to the left hand operator.
>What I'm asking is, given the expression "a*b/c", is there anything in the
>language definition which says that this will be evaluated as:
>
> (a*b)/c
Yes, the associativity rules say that be will be bound to the left hand
operator. Some operators are right associative e.g.
*p++
is interpreted as
*(p++)
and
a = b = c
is interpreted as
a = (b = c)
>or is the compiler free to evaluate it as:
>
> a*(b/c)
>
>if it wishes to do so?
Not if it can produce a different result which is typically the case
when division is involved.
--
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Technical Details
Message-ID:
<912429223snz@genesis.demon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<366155E6.632A909D@erols.com> <912351722.217465@optional.cts.com> <912357376.6545.0.nnrp-03.9e9809e7@news.demon.co.uk> <36618e67.0@isc-newsserver.isc.rit.edu> <912408515.26096.1.nnrp-07.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: fred@genesis.demon.co.uk (Lawrence Kirby) Subject: Re: int / int ? Date: 1998/11/30 Message-ID: <912429223snz@genesis.demon.co.uk> X-Deja-AN: 417076396 References: <366155E6.632A909D@erols.com> <912351722.217465@optional.cts.com> <912357376.6545.0.nnrp-03.9e9809e7@news.demon.co.uk> <36618e67.0@isc-newsserver.isc.rit.edu> <912408515.26096.1.nnrp-07.9e9809e7@news.demon.co.uk> X-Complaints-To: abuse@demon.net X-Mail2News-Path: news.demon.net!genesis.demon.co.uk X-Trace: mail2news.demon.co.uk 912431525 mail2news:4987 mail2news mail2news.demon.co.uk Organization: none Reply-To: fred@genesis.demon.co.uk Newsgroups: comp.os.ms-windows.programmer.misc,borland.public.cpp.language,comp.lang.c