public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Unexpected NaN value
@ 2018-10-04 20:26 Luca Donatini
  2018-10-04 20:30 ` Thomas Koenig
  0 siblings, 1 reply; 3+ messages in thread
From: Luca Donatini @ 2018-10-04 20:26 UTC (permalink / raw)
  To: fortran

Dear all,

I noticed a strange behaviour of the gfortran compiler.

In the source file below, when the real variable b has an "integer-like"
value (e.g. "2", "2.", "2.0" ...) the code correctly writes out a numerical
result. But when a "real-like" value is assigned to b (e.g. "2.1",
"2.0000009", "2.83" ...) , the code writes a NaN value.
This does not occurr when the sample code is compiled with an Intel
compiler (I tested version 2018a).

I have the NaN value problem with both:

   - gfortran 8.2.1 20180831 (Arch Linux package)
   - gfortran 6.3.0 20170516 (Debian Stretch package).


Is this a bug? A known one?

Many thanks in advance for all the clarifications,


Luca Donatini

*** example source file ***

program test
    implicit none

    real :: a = -1.57079637
    real :: b = 2.1

    write(*,*) cos(a)
    write(*,*) cos(a) **(2*b)

end program

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

end of thread, other threads:[~2018-10-04 21:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-04 20:26 Unexpected NaN value Luca Donatini
2018-10-04 20:30 ` Thomas Koenig
2018-10-04 21:17   ` Luca Donatini

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