On writing negative zero - with or without sign



Fortran 77 explicitly forbids output of a negative sign for a zero value.

Fortran 90/95 are intended to be compatible with F77 except where noted. The f90/95 standards omit the statement about not outputting the negative sign for a zero value.

I preparing a patch to gfortran to print the sign for zero values if the signbit is set.

My question is: Should gfortran default behavior omit the negative sign and only show it with a special compiler flag or should the default behavior be to show the negative sign.?

Example code:

REAL :: x,y
character(len=16) :: s1,s2
x=-0.0
y= 0.0
IF (sign(1.0,x).NE.sign(1.0,y)) THEN
write(s1,'(E16.8)') x
write(s2,'(A16)') "-0.00000000E+00"
print *, s1
print *, s2
ENDIF

END

At the moment gfortran does not print the negative sign for x. I am providing that capability, but need interpretation of the standards.

Thanks,

Jerry
.



Relevant Pages

  • Re: Help for a FORTRAN N00b
    ... Will it just report back zero? ... entered "gfortran Elliot4.f95". ... fortran 77 and fortran 95 were basically the same syntax. ...
    (comp.lang.fortran)
  • Re: Help for a FORTRAN N00b
    ... Will it just report back zero? ... entered "gfortran Elliot4.f95". ... fortran 77 and fortran 95 were basically the same syntax. ...
    (comp.lang.fortran)
  • Re: Newbie question about double precision
    ... >>equal to zero. ... of Fortran do not allow it. ...
    (comp.lang.fortran)
  • Re: Finding roots of non-linear equations in Excel
    ... Where's the 'Numeric Recipes in BASIC' book? ... > it's no big deal to find the zero. ... > secant method could all be used (binary search is slowest but also ... Also, you are correct, the Numerical Recipes book is Fortran and C. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: random ints on a large symmetric interval
    ... value is zero. ... gfortran people, I was thinking of it from a gfortran.pdf point of view. ... clock= 392856272 ... summa s is 57129888. ...
    (comp.lang.fortran)