http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47567

--- Comment #6 from Thomas Henlich <thenlich at users dot sourceforge.net> 
2011-02-05 07:40:49 UTC ---
(In reply to comment #3)
> For this special case:
> 
>   print "(F1.0)", 0.0   ! => 0 expected *
> 
> Up to now, we have interpreted the last sentence in F95 10.5.1.2.1 F95 
> 10.2.1.1
> to require this to print '0'.
> 
> "Leading zeros are not permitted except for an optional zero immediately to 
> the
> left of the decimal symbol if the magnitude of the value in the output field 
> is
> less than one. The optional zero shall appear if there would otherwise be no
> digits in the output field."
> 
> F2008 draft has the same wording.  Of course this is a little bit in
> contradiction with another requirement that the decimal point be shown.  I can
> easily change this to output the '*', but thought I would mention that what we
> have now was done on purpose and is even commented so in the code.

Regardless of this choice, the following should all print the same result,
which they currently don't.

print "(F1.0)", 0.0  ! => 0
print "(F1.0)", 0.001 ! => *
print "(F1.0)", 0.01  ! => *
print "(F0.0)", 0.0   ! => 0
print "(F0.0)", 0.001 ! => *
print "(F0.0)", 0.01  ! => *

I don't see anything in the standard which suggests that the exact internal
value 0.0 is to be treated differently from a positive internal value which is
rounded to 0.0 on output, and I don't see a valid reason for doing so.

In extension, the following should also print the same result:

print "(F1.0)", 0.0  ! => 0
print "(F1.0)", 1.0  ! => *
print "(F1.0)", 2.0  ! => *

In all these cases, there is the same issue, that "the decimal point be shown",
but doesn't fit.

Again, I don't see anything in the standard which suggests that the internal
value 0.0 is to be treated differently from a positive internal value which is
rounded to an integer number on output.

And in my opinion, the rule "optional zero shall appear" is not a contradiction
to "the decimal point be shown". Both are required, and the output just doesn't
fit the field, hence the field shall be filled with asterisks.

Reply via email to