Re: how long is double

From: John Potter (jpotter_at_falcon.lhup.edu)
Date: 01/07/04


Date: 7 Jan 2004 13:04:01 -0500

On 7 Jan 2004 03:50:05 -0500, Martijn Lievaart
<m@remove.this.part.rtij.nl> wrote:

> On Tue, 06 Jan 2004 06:35:26 -0500, kanze wrote:

> > I think that this was Francis' point. According to the standard, a+b+c
> > is (a+b)+c. The compiler is free to rearrange this any way it pleases,
> > as long as the results are the same as if it had done (a+b)+c. On most
> > machines, with integer arithmetic, there is no problem. On no machine
> > that I know of, however, can the compiler legally rearrange floating
> > point, unless it absolutely knows the values involved.

> > There was quite a lot of discussion about this when the C standard was
> > first being written. K&R explicitly allowed rearrangement, even when it
> > would result in different results. In the end, the C standard decided
> > not to allow this.

> Then this seems a place where C and C++ differ, see the answer and quote
> from the C++ standard from Ron Natalie.

> Anyone who can confirm this?

His quote is about order of evaluation. It relates to a*b+c*d where
either of a*b or c*d may be evaluated first. In the code under
discussion, a+b+c, it is (a+b)+c. C may be evaluated before a+b but
changing it to a+(b+c) or (a+c)+b is only allowed by the as-if rule.
The non-normative note in 1.9/15 amplifies this. It seems that the
C++ rules are the same as the C rules.

I have no idea how Ron based his other post that claimed an expression
could be reordered giving different results. There is no support in
either of the sited verses.

John

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated. First time posters: Do this! ]



Relevant Pages

  • Re: Evaluating D2005, help needed.
    ... You will see an average loss of about 5Mb. ... We can't upgrade all our machines to 1Gb or more. ... can you post the result of your evaluation of Visual Studio for comparison purposes? ...
    (borland.public.delphi.non-technical)
  • Re: Comparing two machines for changes
    ... Have a look at Winternals "Recovery Manager". ... month in evaluation and are getting ready to purchase it. ... > Is there a way in XP or another 3rd party tool to compare two machines and ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Cappucino Machines - A further question for the experts.
    ... I understand the difference in cost of the machines here ... I realise cost analysis is an intergral part of an evaluation, ... shortfalls from various alties practical experience is going to be ...
    (alt.coffee)
  • SBS 2003 180 Day Evaluation
    ... I want to install SBS 2003 evaluation version on one of ... my machines. ... purchased version do I have to do a complete reinstall? ...
    (microsoft.public.windows.server.sbs)
  • Re: how long is double
    ... > machines, with integer arithmetic, there is no problem. ... > that I know of, however, can the compiler legally rearrange floating ... In the end, the C standard decided ...
    (comp.lang.cpp)