From: chu@tes-mail.jpl.nasa.gov (Eugene Chu)
To: AXP-LIST@redhat.com, axp-list@redhat.com
Subject: Re: g77 real size
Date: Wed, 16 Oct 2002 14:21:42 -0700 (PDT) [thread overview]
Message-ID: <20021016212142.60D7E6F61@tes-mail.jpl.nasa.gov> (raw)
Arkadiy Chapkis wrote:
>Sorry for the off-topic, I just wonder if there's a switch for g77 to
>make a double precision number out of real fp number (not defined, used
>by default). The piece of code
>
> a=1.
> b=a+1./1e12
> c=b-a
> write(*,*) c
> end
>
>compiled with g77 cuts off everything after 8 digits left of point.
>Since what's left are 8 zeros, the result is 0.
>
>I got the (almost) right result using Compaq fort with -real_size 64,
>but don't know that there's something equivalent in g77.
I wish to know the answer to this as well, but I think it's "no";
I did not see that option in g77.
I need the capability for something else, but if you're writing this
data out to a text file (or terminal), you should probably use an
explicit format specification with something like g16.7 for single
precision and g26.17 for double precision. Otherwise, there is no
guarantee that you won't get mostly zeros even with double precision.
As you've already found out, as the magnitude of the value gets
smaller, the free-format output starts turning into zeros, effectively
losing precision. This will happen using this output format even with
double presicion variables, which sort of defeats the purpose of using
double precision in the first place.
eyc
next reply other threads:[~2002-10-16 21:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-16 21:21 Eugene Chu [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-10-16 19:25 g77 real size Arkadiy Chapkis - Arc
2002-10-17 11:24 ` Nelson Brito
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox