This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: Fortran test cases


On Tue, Jan 22, 2019 at 07:59:21AM +0200, Benson Muite wrote:
> 
> 
> On 01/22/2019 07:06 AM, Steve Kargl wrote:
> > On Tue, Jan 22, 2019 at 06:17:14AM +0200, Benson Muite wrote:
> >> Hi,
> >>
> >> Have recently found that when using an installation of gcc gfortran
> >> 8.1.1 and 8.2.1, the double precision computation of sine function can
> >> return a single precision result. The program
> >>
> >> PROGRAM testsin
> >>    real(kind=8) :: pi=3.14159265358979
> > 
> > 3.14159265358979 is a single precision number.
> > 
> There are 14 places after the decimal one can add further digits of pi, 
> the result is the same. Single precision gives results within 7 digits 
> after the decimal 
> (https://en.wikipedia.org/wiki/Single-precision_floating-point_format) 
> double precision should give results within 14 digits after the decimal 
> (https://en.wikipedia.org/wiki/Double-precision_floating-point_format)

program foo
   double precision :: pi = 3.14159265358979
   double precision :: qi = 4 * atan(1.d0)
   write(*,'(F18.16,1X,Z16.16)') pi, pi
   write(*,'(F18.16,1X,Z16.16)') qi, qi
end program foo

 gfcx -O -o z h.f90 && ./z
3.1415927410125732 400921FB60000000
3.1415926535897931 400921FB54442D18

One of these is not good.


-- 
Steve


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