On Thu, 18 Aug 2016, Anton Shterenlikht wrote:
> Date: Thu, 18 Aug 2016 15:42:00 +0100
> From: Anton Shterenlikht <[log in to unmask]>
> Reply-To: Fortran 90 List <[log in to unmask]>
> To: [log in to unmask]
> Subject: Re: COMP-FORTRAN-90 Digest - 16 Aug 2016 to 17 Aug 2016 (#2016-29)
>
>> IEEE -0. results from a calculation of subnormal numbers underflowing to -0.=
>> 0
>>
>> I don't recall another path (other than bit stuffing) to get an IEEE negativ=
>> e zero
>
> complex :: j=cmplx(0.0, -1.0), z=(0.0, -4.0)
> write (*,*) j*z
> end
>
> This gives:
>
> ( -4.00000000 , -0.00000000 )
>
> I don't think there are subnormals or underflow here.
>
> Anton
With the ifort compiler you need the -standard-semantics or -assume minus0
option to get the right behaviour, and as a bonus you are reminded that
list-directed output formatting is very system-dependent:
cayley[~/Jfh] % cat negzero.f90
complex :: j=cmplx(0.0, -1.0), z=(0.0, -4.0)
write (*,*) j*z
end
cayley[~/Jfh] % ifort negzero.f90 ; ./a.out
(-4.000000,0.0000000E+00)
cayley[~/Jfh] % ifort -assume minus0 negzero.f90 ; ./a.out
(-4.000000,-0.0000000E+00)
cayley[~/Jfh] % ifort -standard-semantics negzero.f90 ; ./a.out
(-4.000000,-0.000000)
cayley[~/Jfh] %
-- John Harper, School of Mathematics and Statistics
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail [log in to unmask] phone (+64)(4)463 5276 fax (+64)(4)463 5045
|