Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29073 Discussions

WRITE statement will not print the sign of a negative zero value.

Arebus
Novice
1,038 Views

When writing out a negative zero value to the console, (-0.0) the negative sign is dropped.

For example:

S = -0.000005

 I want to print out a zero value if S is less than my threshold of 0.001

IF(ABS(S) .LT. 0.001) THEN
S=SIGN(0.0, S)

S now equals -0.0

if I now try to write out the variable S to the console using:

write(*,S) 10

10 format('S= ', F10.2)

I get:

S=  0.00

I need to preserve the sign of the original number as it represents a vector quantity.

Is this possible?

Using visual studio 2022, v17.10.5

Fortran compiler 2024.2.0, (IFX)

Fortran F77 compatibility.

 

0 Kudos
1 Solution
TobiasK
Moderator
893 Views
0 Kudos
3 Replies
andrew_4619
Honored Contributor III
965 Views
I am of the opinion that F77 does not have a minus zero concept and that came much later. Stand to be corrected....
0 Kudos
TobiasK
Moderator
894 Views

@Arebus there is an older thread available here:
https://community.intel.com/t5/Intel-Fortran-Compiler/Minus-zero-instead-of-zero/td-p/1090742

can you try to use -assume minus0 ?

0 Kudos
Arebus
Novice
787 Views

Thanks:

Project>Properties>Configuration Properties>Fortran>Floating Point>Enable IEEE Minus Zero Support

Worked, prints out the minus sign.

0 Kudos
Reply