[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: David Monniaux <David.Monniaux@xxxxxxx>*Subject*: Re: Conflicts between C standard and 754-2008*From*: "Hossam A. H. Fahmy" <hfahmy@xxxxxxxxxxxxxxxxxxxxxxx>*Date*: Thu, 6 Jan 2011 15:05:35 +0200*Cc*: stds-754 <stds-754@xxxxxxxxxxxxxxxxx>, stds-1788 <stds-1788@xxxxxxxxxxxxxxxxx>*In-reply-to*: <4D25B359.8040709@xxxxxxx>*List-help*: <http://listserv.ieee.org/cgi-bin/wa?LIST=STDS-754>, <mailto:LISTSERV@LISTSERV.IEEE.ORG?body=INFO%20STDS-754>*List-owner*: <mailto:STDS-754-request@LISTSERV.IEEE.ORG>*List-subscribe*: <mailto:STDS-754-subscribe-request@LISTSERV.IEEE.ORG>*List-unsubscribe*: <mailto:STDS-754-unsubscribe-request@LISTSERV.IEEE.ORG>*References*: <201101012242.p01MgJsb018386@xxxxxxxxxxxxxxxxxxx> <Prayer.1.3.3.1101021513430.4637@xxxxxxxxxxxxxxxxxxxxxx> <20110103211346.GA19559@xxxxxxxxxxxxxxx> <4D22AD01.6030000@xxxxxxxxxxxxx> <20110104061307.D9EE78C01D4@xxxxxxxxx> <AANLkTi==euYs9gAfB2+LXcxT5o69YmaKbz920s3SNe4b@xxxxxxxxxxxxxx> <4D25B359.8040709@xxxxxxx>*Sender*: stds-754@xxxxxxxx

2011/1/6 David Monniaux <David.Monniaux@xxxxxxx>

Yes, commutativity is the swapping of the terms around the operator but in the examples:

Âx=100,Â y=1e+30,Â z=1e+30

Â z-y+x=100

Â z+x-y=0

and without any parenthesis I assumed that the evaluation will always proceed from left to right and I swapped the second and third term. So we are getting:

(z-y)+x = 100

and

(z+x)-y=0

which is as expected in 754. However, C says that (-y)+x is the same as x+(-y) so an optimizing compiler can assume that the two statements z-y+x and z+x-y (just commutativity on the 2nd and 3rd term) are equivalent which they are not under 754.

Does this explain better the point of conflict that I imagine?

--

Hossam A. H. Fahmy

Associate Professor

Electronics and Communications Engineering

Cairo University

Egypt

On 01/06/2011 12:39 PM, Hossam A. H. Fahmy wrote:As far as I understand, you are referring to associativity, not

> I am a bit troubled by this since it means that C assumes that FP

> addition is commutative in general which is not true. It is specifically

> wrong if applied on more than two terms. For example,

commutativity:

(a + b) + c == a + (b + c)

Commutativity is just the permission to swap the two operands to a +.

Yes, commutativity is the swapping of the terms around the operator but in the examples:

Âx=100,Â y=1e+30,Â z=1e+30

Â z-y+x=100

Â z+x-y=0

and without any parenthesis I assumed that the evaluation will always proceed from left to right and I swapped the second and third term. So we are getting:

(z-y)+x = 100

and

(z+x)-y=0

which is as expected in 754. However, C says that (-y)+x is the same as x+(-y) so an optimizing compiler can assume that the two statements z-y+x and z+x-y (just commutativity on the 2nd and 3rd term) are equivalent which they are not under 754.

Does this explain better the point of conflict that I imagine?

--

Hossam A. H. Fahmy

Associate Professor

Electronics and Communications Engineering

Cairo University

Egypt

**Follow-Ups**:**Re: Conflicts between C standard and 754-2008***From:*Vincent Lefevre

**References**:**Re: Conflicts between C standard and 754-2008***From:*Vincent Lefevre

**Re: Conflicts between C standard and 754-2008***From:*Dan Zuras IEEE

**Re: Conflicts between C standard and 754-2008***From:*Hossam A. H. Fahmy

**Re: Conflicts between C standard and 754-2008***From:*David Monniaux

- Prev by Date:
**Re: Conflicts between C standard and 754-2008** - Next by Date:
**Re: Conflicts between C standard and 754-2008** - Previous by thread:
**Re: Conflicts between C standard and 754-2008** - Next by thread:
**Re: Conflicts between C standard and 754-2008** - Index(es):