This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Problem with nearest(tiny(o),-1.0)/2.0
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Dominique Dhumieres <dominiq at lps dot ens dot fr>
- Cc: fortran at gcc dot gnu dot org
- Date: Tue, 4 Apr 2006 20:07:46 -0700
- Subject: Re: Problem with nearest(tiny(o),-1.0)/2.0
- References: <443242F8.mailG6611O2GU@tournesol.lps.ens.fr>
On Tue, Apr 04, 2006 at 11:57:12AM +0200, Dominique Dhumieres wrote:
> The following program
>
> program chop
> real o, t, td, tu, x, y
> o = 1.
> t = tiny(o)
> td = nearest(t,-1.0)
> x = td/2.0
> y = nearest(tiny(o),-1.0)/2.0
> print *, x, y, x - y
> end program chop
>
> gives
>
> 5.8774718E-39 5.8774704E-39 1.4012985E-45
>
This appears to be a problem with the constant folding
of nearest() in simplify.c. I believe this problem
will be observed only iin situations where subnormal numbers
occur (ie., in the above corner case). There is a TODO
to use newer MPFR functions, but this would require people
to upgrade to 2.2.0. I'll investigate this weekend.
--
Steve