commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <>
Subject Re: [Math] x + h - x != h
Date Wed, 16 Nov 2011 19:19:55 GMT
On Wed, Nov 16, 2011 at 8:19 AM, Gilles Sadowski <> wrote:

> 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
> ?

No.  Just that the in-lined code will disappear.

I don't think that the JIT is naive enough to simplify away the subtraction.

> The issue is whether an optimization could do that transformation.

If there are cases where IEEE FP arithmetic allows

    x + delta - x != delta

then the optimization should not happen.  Obviously, if x is NaN or
infinite, this holds.  Also, it is clear that (x+delta) - x != delta for
some values of delta so I doubt that the optimization happens.

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

If you didn't actually use the results, then it will disappear.  If you
called the java.math routines to do this, then those may be known to be
inverses and disappear as well.  If you called your own implementations and
actually use the bits, then it will probably survive.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message