commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: [Math] x + h - x != h
Date Wed, 16 Nov 2011 16:19:40 GMT
On Wed, Nov 16, 2011 at 07:52:27AM -0800, Ted Dunning wrote:
> The JVM is likely to in-line dummy, realize it does nothing and then
> coalesce your other code.
> 
> It isn't any wonder that this produces the same results.

I'm not sure I understand what you mean: Does "coalesce" means that
  x + delta - x
will be equal to
  delta
?

The issue is whether an optimization could do that transformation.

[Note that I did not implement any "dummy" function but rather called the
quite non-dummy "doubleToLongBits" and "longBitsToDouble".]


Gilles

> On Wed, Nov 16, 2011 at 5:28 AM, Gilles Sadowski <
> gilles@harfang.homelinux.org> wrote:
> 
> > Besides
> >  x + delta - x
> > being strange-looking and running the risk of being manually (and
> > incorrectly) changed to just
> >  delta
> > the reference (not) cited above suggests to use a two- or three-steps
> > procedure to ensure that some optimizing compiler will not do the same:
> > ---CUT---
> >  double sum = x + delta;
> >  dummy(sum); // function "dummy" does nothing.
> >  delta = sum - x;
> > ---CUT---
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message