public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/98201] New: CSQRT function gives bad resuts at runtime
@ 2020-12-08 14:44 pozar at ecs dot umass.edu
  2020-12-08 15:34 ` [Bug fortran/98201] " tkoenig at gcc dot gnu.org
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: pozar at ecs dot umass.edu @ 2020-12-08 14:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98201

            Bug ID: 98201
           Summary: CSQRT function gives bad resuts at runtime
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pozar at ecs dot umass.edu
  Target Milestone: ---

I am running mingw gfortran 9.2.0 on Windows 7, and have a problem with results
from the CSQRT function during runtime. Sample code below, with results.
Starting with a complex argument having increasingly large real part, and a
relatively small imaginary part, csqrt initially gives a correct result (as
tested by squaring the result from CSQRT). But the second row shows some
significant error, and later rows show 'Infinity' for the imaginary part.
(using sq = z**.5 gives correct results)


F95 CODE;

! test CSQRT
    complex z, sq
    write(6,*) "         Argument                SquareRoot               SR
squared"
    do n=1,9
        z=-10.**n+(0.,.1)
        sq=csqrt(z)
        write(*,1) z, sq, sq*sq
    end do
1   format(3("(",e10.4,2x,e10.4,")",3x))
pause

RESULTS:
          Argument                  SquareRoot               SR squared
(-.1000E+02  0.1000E+00)   (0.1581E-01  0.3163E+01)   (-.1001E+02  0.1000E+00)
(-.1000E+03  0.1000E+00)   (0.5167E-02  0.9676E+01)   (-.9362E+02  0.1000E+00)
(-.1000E+04  0.1000E+00)   (0.0000E+00    Infinity)   ( -Infinity         NaN)
(-.1000E+05  0.1000E+00)   (0.0000E+00    Infinity)   ( -Infinity         NaN)
(-.1000E+06  0.1000E+00)   (0.0000E+00    Infinity)   ( -Infinity         NaN)
(-.1000E+07  0.1000E+00)   (0.0000E+00    Infinity)   ( -Infinity         NaN)
(-.1000E+08  0.1000E+00)   (0.0000E+00    Infinity)   ( -Infinity         NaN)
(-.1000E+09  0.1000E+00)   (0.0000E+00    Infinity)   ( -Infinity         NaN)
(-.1000E+10  0.1000E+00)   (0.0000E+00    Infinity)   ( -Infinity         NaN)
PAUSE

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

end of thread, other threads:[~2021-03-28 13:16 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 14:44 [Bug fortran/98201] New: CSQRT function gives bad resuts at runtime pozar at ecs dot umass.edu
2020-12-08 15:34 ` [Bug fortran/98201] " tkoenig at gcc dot gnu.org
2020-12-08 15:35 ` dominiq at lps dot ens.fr
2020-12-08 15:47 ` dpozar at ecs dot umass.edu
2020-12-08 15:54 ` dpozar at ecs dot umass.edu
2020-12-08 15:55 ` tkoenig at gcc dot gnu.org
2020-12-08 16:27 ` dpozar at ecs dot umass.edu
2020-12-08 17:36 ` kargl at gcc dot gnu.org
2020-12-08 18:19 ` tkoenig at gcc dot gnu.org
2020-12-08 19:13 ` dpozar at ecs dot umass.edu
2020-12-08 19:27 ` tkoenig at gcc dot gnu.org
2020-12-08 20:46 ` dpozar at ecs dot umass.edu
2020-12-08 22:06 ` kargl at gcc dot gnu.org
2020-12-09  0:28 ` dpozar at ecs dot umass.edu
2020-12-09  4:38 ` sgk at troutmask dot apl.washington.edu
2020-12-09 13:24 ` dpozar at ecs dot umass.edu
2020-12-09 15:37 ` sgk at troutmask dot apl.washington.edu
2020-12-09 16:04 ` dpozar at ecs dot umass.edu
2021-03-28 12:38 ` dominiq at lps dot ens.fr
2021-03-28 13:05 ` dpozar at ecs dot umass.edu
2021-03-28 13:16 ` dominiq at lps dot ens.fr

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).