Signed zero

Signed zero

Hello, I have a question about signes zero-values in a FORMAT-output.

The following code gives me as output -0.00.

    program TestNegZero
    implicit none
    real*8 dTest
    end program TestNegZero

In my old compiler (Compaq Visual Fortran), I got as output 0.00. I would like to achieve to get this output again, because I have a big program with calculation-outputs and there are now many cases with  -0,00 as output.

Till now, I did not find a setting to manipulate the behaviour, is there a solution?

Thanks a lot for any advice and greetings from germany (therefore my english is not so perfect)

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The CVF behavior was a bug. The standard requires that there be a sign when the original value is negative, even if it rounds to zero. There's no way to change this, sorry.

Retired 12/31/2016

OK, thanks for the info.

I just found out, that with the compiler-setting /vms (enable VMS Compatibility) the output is not signes anymore, but I think, this setting will for sure make me other problems.

So it seems, the onliest solution is to round myself every output. 


No, /vms is doing something different here - it's establishing Fortran carriage control so that the sign is interpreted as carriage control. If you change the format to "1x,f5.2" you'll see the sign, even with /vms.

You could use an internal write and write to a string, and then if the string was equal to "-0.00" change it to " 0.00".

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today