g95 writes 0.232699336-309 instead of 0.000000000E+00
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
g95 writes 0.232699336-309 instead of 0.000000000E+00         


Author: louisJ
Date: May 16, 2008 06:09

Hi

I compile my code with g95.
I write in a file a variable that has been set to 0.
and when I open the file I see 0.232699336-309 (yes, without the
'E') instead of the expected 0.000000000E+00.
For information, when I compile with ifort I don't have this error.
This is free fortran format. On a 64bit machine.
Any idea how to avoid this, i.e. write the expected 0.000000000E+00
or 0.232699336E-309 (with the 'E') ?
18 Comments
Re: g95 writes 0.232699336-309 instead of 0.000000000E+00         


Author: Michael Metcalf
Date: May 16, 2008 06:43

"louisJ" gmail.com> wrote in message
news:2a402794-927d-41ca-856f-45c59b9d4a50@b1g2000hsg.googlegroups.com...
> Hi
>
> I compile my code with g95.
> I write in a file a variable that has been set to 0.
> and when I open the file I see 0.232699336-309 (yes, without the
> 'E') instead of the expected 0.000000000E+00.
> For information, when I compile with ifort I don't have this error.
> This is free fortran format. On a 64bit machine.
> Any idea how to avoid this, i.e. write the expected 0.000000000E+00
> or 0.232699336E-309 (with the 'E') ?

To get the E you need a format specification like e16.9e4 ("Fortran 95/2003
Explained", Section 9.12.2). Why it's not 0 is another matter.

Regards,

Mike Metcalf
no comments
Re: g95 writes 0.232699336-309 instead of 0.000000000E+00         


Author: louisJ
Date: May 16, 2008 07:01

yes this what I do:
17E17.9
no comments
Re: g95 writes 0.232699336-309 instead of 0.000000000E+00         


Author: Michael Metcalf
Date: May 16, 2008 07:07

"louisJ" gmail.com> wrote in message
news:ddfda91b-f0cb-4e50-be1e-c32886c834c8@a1g2000hsb.googlegroups.com...
> yes this what I do:
> 17E17.9

No it isn't, I said e16.9e4, or e17.9e4 if you want. Note the two e's!!!

Regards,

Mike Metcalf
no comments
Re: g95 writes 0.232699336-309 instead of 0.000000000E+00         


Author: Dick Hendrickson
Date: May 16, 2008 08:08

louisJ wrote:
> Hi
>
> I compile my code with g95.
> I write in a file a variable that has been set to 0.
> and when I open the file I see 0.232699336-309 (yes, without the
> 'E') instead of the expected 0.000000000E+00.
> For information, when I compile with ifort I don't have this error.
> This is free fortran format. On a 64bit machine.
> Any idea how to avoid this, i.e. write the expected 0.000000000E+00
> or 0.232699336E-309 (with the 'E') ?

How do you know you are setting it to zero? Do you actually
say
variable = 0
or are you doing something like
variable = 1 -(sin(x)**2 + cos(x)**2)
where the answer should mathematically be zero, but is likely to
be off by a bit or two computationally.

Dick Hendrickson
no comments
Re: g95 writes 0.232699336-309 instead of 0.000000000E+00         


Author: nospam
Date: May 16, 2008 08:16

Dick Hendrickson att.net> wrote:
> louisJ wrote:
>> I write in a file a variable that has been set to 0.
>> and when I open the file I see 0.232699336-309
> How do you know you are setting it to zero? Do you actually
> say
> variable = 0
> or are you doing something like
> variable = 1 -(sin(x)**2 + cos(x)**2)
> where the answer should mathematically be zero, but is likely to
> be off by a bit or two computationally.

That's a bit smaller that I'd expect from such roundoff. Not to say it
is impossible, but the order of magnitude makes me more suspicious of
things like type disagreements in argument passing. That's about the
order of magnitude you tend to get from trying to misinterpret the bits
in a single precision real (and whatever follows it in memory) as double
precision.

Michael covered the lack of the E.
Show full article (1.06Kb)
no comments
Re: g95 writes 0.232699336-309 instead of 0.000000000E+00         


Author: louisJ
Date: May 16, 2008 08:29

On May 16, 5:08 pm, Dick Hendrickson att.net> wrote:
> louisJ wrote:
>> Hi
>
>> I compile my code with g95.
>> I write in a file a variable that has been set to 0.
>> and when I open the file I see 0.232699336-309 (yes, without the
>> 'E') instead of the expected 0.000000000E+00.
>> For information, when I compile with ifort I don't have this error.
>> This is free fortran format. On a 64bit machine.
>> Any idea how to avoid this, i.e. write the expected 0.000000000E+00
>> or 0.232699336E-309 (with the 'E') ?
>
> How do you know you are setting it to zero? Do you actually
> say
> variable = 0
> or are you doing something like
> variable = 1 -(sin(x)**2 + cos(x)**2)
> where the answer should mathematically be zero, but is likely to
> be off by a bit or two computationally. ...
Show full article (0.91Kb)
no comments
Re: g95 writes 0.232699336-309 instead of 0.000000000E+00         


Author: Herman D. Knoble
Date: May 16, 2008 08:39

On Fri, 16 May 2008 08:29:35 -0700 (PDT), louisJ gmail.com> wrote:

-|On May 16, 5:08 pm, Dick Hendrickson att.net> wrote:
-|> louisJ wrote:
-|> > Hi
-|>
-|> > I compile my code with g95.
-|> > I write in a file a variable that has been set to 0.
-|>...
Show full article (1.19Kb)
no comments
Re: g95 writes 0.232699336-309 instead of 0.000000000E+00         


Author: Alois Steindl
Date: May 16, 2008 08:37

louisJ gmail.com> writes:
>
> yes I write varaible = 0. (double precision, real*8)
Hello,
can you provide a minimal example, where this effect occurs?
What do you get, if you print the variable immediately after this
assignment?
Alois
no comments
Re: g95 writes 0.232699336-309 instead of 0.000000000E+00         


Author: Gib Bogle
Date: May 16, 2008 13:41

louisJ wrote:
> On May 16, 5:08 pm, Dick Hendrickson att.net> wrote:
>> louisJ wrote:
>>> Hi
>>> I compile my code with g95.
>>> I write in a file a variable that has been set to 0.
>>> and when I open the file I see 0.232699336-309 (yes, without the
>>> 'E') instead of the expected 0.000000000E+00.
>>> For information, when I compile with ifort I don't have this error.
>>> This is free fortran format. On a 64bit machine.
>>> Any idea how to avoid this, i.e. write the expected 0.000000000E+00
>>> or 0.232699336E-309 (with the 'E') ?
>> How do you know you are setting it to zero? Do you actually
>> say
>> variable = 0
>> or are you doing something like
>> variable = 1 -(sin(x)**2 + cos(x)**2)
>> where the answer should mathematically be zero, but is likely to
>> be off by a bit or two computationally.
>> ...
Show full article (0.99Kb)
no comments
1 2