Expected precision of Fortran FE constant evaluation

Richard Biener rguenther@suse.de
Fri Feb 8 19:06:00 GMT 2019


On February 8, 2019 7:50:33 PM GMT+01:00, Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
>On Fri, Feb 08, 2019 at 07:27:25PM +0100, Jakub Jelinek wrote:
>> On Fri, Feb 08, 2019 at 10:21:27AM -0800, Steve Kargl wrote:
>> > result = 0
>> > result = result + 1.**2        ! result = 1
>> > result = result + 2.**2        ! result = 5
>> > result = result + huge(1.)**2  ! result = huge**2, same as 1 -
>epsilon/2 = 1
>> > result = sqrt(result)          ! result = huge
>> > 
>> > In looking at the code, there is no range_checking for norm2.
>> 
>> Thanks for looking at it.  I guess for the PR which wants to set
>emin/emax
>> globally (unless temporarily overridden) the question is, can we
>throw away
>> the failing tests from norm2_3.f90 or replace the huge in there with
>> something smaller (I mean smaller than sqrt(huge()), so that **2 is
>still
>> finite) and adding 5 to it is too.
>> 
>
>Does norm2_1.f90 also fail?  It looks like norm2_1.f90
>and norm2_3.f90 are identical except norm2_1.f90 is 
>for REAL(4) and norm2_3.f90 is for REAL(16).

The real(4) case doesn't fail because mpfr is set up for real(16) precision... 

It's really just done to limit its attempts at producing an nearly infinite precision result and thus compile time. 

Richard. 
>
>At any rate, yes, I think we can remove or change
>the HUGE() testcases.



More information about the Fortran mailing list