signed zeros
Steve Kargl
sgk@troutmask.apl.washington.edu
Fri Jul 30 00:22:00 GMT 2010
On Thu, Jul 29, 2010 at 08:15:43PM -0400, Jack Howarth wrote:
> On Thu, Jul 29, 2010 at 05:11:48PM -0700, Steve Kargl wrote:
> > On Thu, Jul 29, 2010 at 08:04:22PM -0400, Jack Howarth wrote:
> > >
> > > Steve,
> > > Well the current behavior is rather silly. It assumes
> > > that the user should be told that a value truncated in
> > > output is a non-zero negative value whereas it is silent
> > > on the case of positive numbers that are non-zero. If one
> > > is going to this extreme with i/o, the compiler should be
> > > emitting...
> > >
> > > -0.0000 for values less than zero
> > > 0.0000 for zero itself
> > > +0.0000 for values greater than zero
> > >
> > > Otherwise we should at least try to find another fortran
> > > compiler than supports this weird behavior.
> > > Jack
> >
> > Apparently, you have had no formal training in real analysis
> > where -0 is an important entity. Note, the standard explicitly
> > states a leading + sign can be omitted. You can force the plus
> > sign if you like:
> >
> > troutmask:kargl[207] cat a.f90
> > STEPCH=0.2511847893E-05
> > WRITE(6,'(A,SP,F10.4)') ' ------ stepsize=',STEPCH
> > END
> > troutmask:kargl[208] ~/../sgk/work/4x/bin/gfortran -o z a.f90 && ./z
> > ------ stepsize= +0.0000
> >
>
> Steve,
> Again, point me to another fortran compiler with this
> behavior. Ruthlessly strict interpretations of the standard
> which creates a compiler with unconventional behavior is
> of limited use. Especially when running testsuites which
> must compare the logged output for more than just gfortran
> builds of the software.
> Jack
>
Just use the -fno-sign-zero option.
PS: I don't care what other compilers do.
PPS: Here's another option if you want +0.
troutmask:kargl[210] cat a.f90
STEPCH=0.2511847893E-05
open(unit=6,sign='plus')
WRITE(6,'(A,F10.4)') ' ------ stepsize=',STEPCH
END
troutmask:kargl[211] ~/../sgk/work/4x/bin/gfortran -o z a.f90 && ./z
------ stepsize= +0.0000
--
Steve
More information about the Fortran
mailing list