This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH/gfortran] Fix rounding in constant folding


Tobias Schlüter wrote:
> Steve Kargl wrote:
> 
>>>In order of increasing probability: Does mpfr round incorrectly? Do we do
>>>something wrong?  Or am I being stupid?
> 
> 
> Further investigation proved the last of these options to be the case.

Hm, upon looking at this again, this is not the case, and therefore is the
case again.  The important conclusion is that our implementation of NEAREST is
wrong:
[tobi@marktplatz tests]$ cat prec.f90
print *, 0.49999997, nint (0.49999997)
print *, nearest (0.5, -1.), nint(nearest (0.5, -1.))
x = 0.5
print *, nearest (x, -1.), nint(nearest(x,-1.))
end

gives the following output:
  0.5000000               1
  0.4999999               0
  0.5000000               0
So the result for NEAREST as evaluated by the constant folders is too small.
It looks like mpfr provides what is needed, so I'll cook up a patch.

- Tobi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]