J3/06-126
To: J3
From: Michael Ingrassia
Subject: Formatted output of a negative real zero value
Date: 2006 January 30
NUMBER: F03/0080
TITLE: Formatted output of a negative real zero value
KEYWORDS: formatted output, negative zero, IEEE
DEFECT TYPE: CLARIFICATION/ERRATUM
STATUS: J3 consideration in progress
QUESTION:
Suppose a Fortran processor's representation of
the real zero value is signed. When a negative
real zero value is written using formatted output:
(a) Does the Fortran 2003 standard allow the
representation of the zero value in the
output field to be prefixed with a minus
sign?
(b) Does the Fortran 2003 standard require the
representation of the zero value in the
output field to be prefixed with a minus
sign?
ANSWER: (a) Yes. Although Section 4.4.2 lists some
contexts as requiring positive and negative zeros to
be treated as equivalent, formatted output is not
on that list of contexts. Negative zero can already
be produced by formatted output, for example by
PRINT '(F4.1)', -0.000001
which in Fortran 95 (but not Fortran 90) is required
to write "-0.0" or " -.0".
(b) Yes, or Not Necessarily (edits provided for both). The first
choice promotes portability.
(b1) The negative sign is required to appear in formatted output
of a negative zero value.
(b2) Negative zero values may be treated as negative values
in formatted output at the option of the implementor.
DISCUSSION: A negative zero value is negative by name but zero
by nature. Therefore a context which refers to negative values
must always be inspected to see if it is appropriate
to also include negative zero values, and the instance in 10.6.1
needs amendment.
EDITS:
For (b1):
[227:3-4] Change from
The representation of a negative internal value in the field
shall be prefixed with a minus sign.
to
The representation of a negative internal value or a negative
zero value in the field shall be prefixed with a minus sign.
For (b2):
[227:4] Add the sentence
The representation of a negative zero value
in the field may be prefixed with a minus sign.
SUBMITTED BY: Michael Ingrassia
HISTORY: J3/06-126 submitted to J3 meeting 175