public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION
@ 2004-04-29 18:01 gcc-bugzilla at gcc dot gnu dot org
  2004-04-29 18:13 ` [Bug fortran/15205] [gfortran] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-04-29 18:01 UTC (permalink / raw)
  To: gcc-bugs


The NEAREST intrinsic for DOUBLE PRECISION kind type is returning the
wrong value.  Consider the following program:

  program test_nearest

  implicit none

  real(4) sr, sx, ss
  real(8) dr, dx, ds

  sx = 1.237e0_sp
  ss = 1.e0_sp
  sr = nearest(sx,ss)
  write(*,1) 'nearest(', sx, ',', ss, ') = ', sr
1 format(a,e15.8,a,e15.8,a,e15.8)
  ss = -1.e0_sp
  sr = nearest(sx,ss)
  write(*,1) 'nearest(', sx, ',', ss, ') = ', sr

  dx = 1.237e0_dp
  ds = 1.e0_dp
  dr = nearest(dx,ds)
  write(*,2) 'nearest(', dx, ',', ds, ') = ', dr
2 format(a,e23.16,a,e23.16,a,e23.16)
  ds = -1.e0_dp
  dr = nearest(dx,ds)
  write(*,2) 'nearest(', dx, ',', ds, ') = ', dr

end program test_nearest

Gfortran yields

kargl[328] ./nearest
nearest( 0.12369999E+01, 1.00000000E+00) =  0.12370001E+01
nearest( 0.12369999E+01,-1.00000000E+00) =  0.12369998E+01
nearest( 0.1237000000000000E+01, 1.0000000000000000E+00) = -0.4303249471964870E-36
nearest( 0.1237000000000000E+01,-1.0000000000000000E+00) = -0.4303249471964870E-36

NAG's compiler gives

nearest( 0.12370000E+01, 0.10000000E+01) =  0.12370001E+01
nearest( 0.12370000E+01,-0.10000000E+01) =  0.12369999E+01
nearest( 0.1237000000000000E+01, 0.1000000000000000E+01) =  0.1237000000000000E+01
nearest( 0.1237000000000000E+01,-0.1000000000000000E+01) =  0.1237000000000000E+01

Environment:
System: FreeBSD c-67-168-59-70.client.comcast.net 5.2-CURRENT FreeBSD 5.2-CURRENT #2: Sat Apr 24 10:33:08 PDT 2004 kargl@c-67-168-59-70.client.comcast.net:/usr/obj/usr/src/sys/HOTRATS i386


	
host: i386-unknown-freebsd5.2
build: i386-unknown-freebsd5.2
target: i386-unknown-freebsd5.2
configured with: ../gcc/configure --prefix=/home/kargl/gcc/work --disable-libmudflap --enable-languages=c,f95 --with-gmp=/usr/local

How-To-Repeat:
	See above.

-- 
           Summary: NEAREST intrinsic returns wrong value in DOUBLE
                    PRECISION
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kargl at c-67-168-59-70 dot client dot comcast dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-unknown-freebsd5.2
  GCC host triplet: i386-unknown-freebsd5.2
GCC target triplet: i386-unknown-freebsd5.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-05-14 14:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
2004-04-29 18:13 ` [Bug fortran/15205] [gfortran] " pinskia at gcc dot gnu dot org
2004-04-29 18:57 ` [Bug libfortran/15205] " pinskia at gcc dot gnu dot org
2004-04-30  0:51 ` bdavis9659 at comcast dot net
2004-04-30 16:44 ` [Bug fortran/15205] " Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-04-30 17:06 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-04-30 18:13 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-05-01  3:01 ` bdavis at gcc dot gnu dot org
2004-05-08 16:17 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-05-08 17:28 ` pinskia at gcc dot gnu dot org
2004-05-14 18:38 ` cvs-commit at gcc dot gnu dot org
2004-05-14 18:52 ` tobi at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).