On writing negative zero - with or without sign
- From: Jerry DeLisle <jvdelisle@xxxxxxxxxxx>
- Date: Sun, 08 Jul 2007 20:14:45 GMT
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
.
- Follow-Ups:
- Re: On writing negative zero - with or without sign
- From: robert . corbett
- Re: On writing negative zero - with or without sign
- From: glen herrmannsfeldt
- Re: On writing negative zero - with or without sign
- From: James Giles
- Re: On writing negative zero - with or without sign
- Prev by Date: Re: how to avoid auto new line?
- Next by Date: matmul trouble
- Previous by thread: Will Intel Visual Fortran 10.1 do automatic vectorization for me?
- Next by thread: Re: On writing negative zero - with or without sign
- Index(es):
Relevant Pages
|