signed zeros

Steve Kargl sgk@troutmask.apl.washington.edu
Thu Jul 29 23:57:00 GMT 2010


On Thu, Jul 29, 2010 at 06:58:51PM -0400, Jack Howarth wrote:
>    Why does gfortran output...
> 
>  ------ stepsize=   -0.0000
> 
> for the code...
> 
>       STEPCH=-0.2511847893E-05
>       WRITE(6,'(A,F10.4)') ' ------ stepsize=',STEPCH
>       END
> 
> whereas other fortran compilers like ifort 11.0 outputs...
> 
>  ------ stepsize=    0.0000
> 
> I see the same unsigned output from SGI's old fort77.
> Why was it decided to have gfortran emit the sign for
> this case? Shouldn't gfortran's i/o check to see if
> only zeros are to be printed and remove the sign in
> that case?

Perhaps, gfortran can distinguish between +0 and -0,
and the other compilers cannot.

The standard states:

   The real type includes a zero value.  Processors that
   distinguish between positive and negative zeros shall
   treat them as equivalent
   (1)   in all relational operations,
   (2)   as actual arguments to intrinsic procedures other
         than those for which it is explicitly specified
         that negative zero is distinguished, and
   (3)   as the scalar-numeric-expr in an arithmetic IF.

The list above does not include IO.

-- 
Steve



More information about the Fortran mailing list