For Programmers: Free Programming Magazines  


Home > Archive > Fortran > May 2006 > controlling formatting of signed zeros









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author controlling formatting of signed zeros
robert.corbett@sun.com

2006-05-28, 8:04 am

I am considering adding some new edit descriptors to Sun f90/f95
to control the way the signs of floating-point zeros are treated in
formatted output. The new edit descriptors are: ZP, ZS and ZU.
The edit descriptor ZP causes floating-point zeros to be
formatted in the same manner as positive floating-point values,
regardless of the signs of the zeros. The edit descriptor ZS causes
negative floating-point zeros to be formatted in the same manner
as negative values and positive zeros to be formatted in the same
manner as positive values. The edit descriptor ZU supresses
production of signs for zeros even when the sign mode is PLUS.

I would like to know what people think of my proposal.

One might at first think that introducing an edit descriptor that
starts
with the letter Z could lead to a problem, because there already is
a Z edit descriptor. There is no problem. The situation is much
the same as is the case for the B, BN, and BZ edit descriptors.

The idea for the ZU edit descriptor came from reading old books
of tables of functions. Some of the tables associate a sign with all
values other than those values that are exact zeros. That
convention provides a way to distinguish between a value that is
so close to zero that it is displayed as zero and a true zero. Tables
of functions tended to display values in fixed-point notation rather
than floating-point notation. I use the word "tended" because the
tables for functions with widely varying ranges did use a form of
floating-point notation.

I developed my proposal in response to a request from John Harper.
My proposal differs completely from what he proposed, but it offers
the same functionality.

Bob Corbett

Gordon Sande

2006-05-28, 7:06 pm

On 2006-05-28 07:05:33 -0300, robert.corbett@sun.com said:

> I am considering adding some new edit descriptors to Sun f90/f95
> to control the way the signs of floating-point zeros are treated in
> formatted output. The new edit descriptors are: ZP, ZS and ZU.
> The edit descriptor ZP causes floating-point zeros to be
> formatted in the same manner as positive floating-point values,
> regardless of the signs of the zeros. The edit descriptor ZS causes
> negative floating-point zeros to be formatted in the same manner
> as negative values and positive zeros to be formatted in the same
> manner as positive values. The edit descriptor ZU supresses
> production of signs for zeros even when the sign mode is PLUS.
>
> I would like to know what people think of my proposal.
>
> One might at first think that introducing an edit descriptor that
> starts
> with the letter Z could lead to a problem, because there already is
> a Z edit descriptor. There is no problem. The situation is much
> the same as is the case for the B, BN, and BZ edit descriptors.
>
> The idea for the ZU edit descriptor came from reading old books
> of tables of functions. Some of the tables associate a sign with all
> values other than those values that are exact zeros. That
> convention provides a way to distinguish between a value that is
> so close to zero that it is displayed as zero and a true zero. Tables
> of functions tended to display values in fixed-point notation rather
> than floating-point notation. I use the word "tended" because the
> tables for functions with widely varying ranges did use a form of
> floating-point notation.
>
> I developed my proposal in response to a request from John Harper.
> My proposal differs completely from what he proposed, but it offers
> the same functionality.
>
> Bob Corbett


Once upon a time I seem to recall there was a system in which an
exact zero was formatted out as "0.0" even under F10.3, with the
decimal point position presrved by the placemant of blanks. This
allowed for the distinction between "zero" and "rounded to zero".
At this point I do not recall if the display was produced by
pre-standardization I/O or was the result of careful progammer
editing of output.

There are current examples of official statistical publications were
rounded to zero gets its own unique symbol, typically "*". There the
important semantics are between no activity and small activity.

I am not quite clear how ZU above distinguishes between "true zero"
and "displays as zero". Or is the problem mentioned but not addressed.



Gary L. Scott

2006-05-28, 7:06 pm

robert.corbett@sun.com wrote:
> I am considering adding some new edit descriptors to Sun f90/f95
> to control the way the signs of floating-point zeros are treated in
> formatted output. The new edit descriptors are: ZP, ZS and ZU.
> The edit descriptor ZP causes floating-point zeros to be
> formatted in the same manner as positive floating-point values,
> regardless of the signs of the zeros. The edit descriptor ZS causes
> negative floating-point zeros to be formatted in the same manner
> as negative values and positive zeros to be formatted in the same
> manner as positive values. The edit descriptor ZU supresses
> production of signs for zeros even when the sign mode is PLUS.
>
> I would like to know what people think of my proposal.
>
> One might at first think that introducing an edit descriptor that
> starts
> with the letter Z could lead to a problem, because there already is
> a Z edit descriptor. There is no problem. The situation is much
> the same as is the case for the B, BN, and BZ edit descriptors.
>
> The idea for the ZU edit descriptor came from reading old books
> of tables of functions. Some of the tables associate a sign with all
> values other than those values that are exact zeros. That
> convention provides a way to distinguish between a value that is
> so close to zero that it is displayed as zero and a true zero. Tables
> of functions tended to display values in fixed-point notation rather
> than floating-point notation. I use the word "tended" because the
> tables for functions with widely varying ranges did use a form of
> floating-point notation.
>
> I developed my proposal in response to a request from John Harper.
> My proposal differs completely from what he proposed, but it offers
> the same functionality.
>
> Bob Corbett
>

Would rather that any extensions be prefixed with "SUN" (or some such)
so that it is clear to the programmer that he is using an extension.
Otherwise, don't add such things until it is approved for F2k8+/-.

--

Gary Scott
mailto:garyscott@ev1.net

Fortran Library: http://www.fortranlib.com

Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html

Why are there two? God only knows.


If you want to do the impossible, don't hire an expert because he knows
it can't be done.

-- Henry Ford
jamesgiles@att.net

2006-05-28, 7:06 pm


robert.corbett@sun.com wrote:
> I am considering adding some new edit descriptors to Sun f90/f95
> to control the way the signs of floating-point zeros are treated in
> formatted output. The new edit descriptors are: ZP, ZS and ZU.
> The edit descriptor ZP causes floating-point zeros to be
> formatted in the same manner as positive floating-point values,
> regardless of the signs of the zeros. The edit descriptor ZS causes
> negative floating-point zeros to be formatted in the same manner
> as negative values and positive zeros to be formatted in the same
> manner as positive values. The edit descriptor ZU supresses
> production of signs for zeros even when the sign mode is PLUS.


Well, I'm on travel so I don't have the reference handy, but
it's known that modes inhibit productivity. Especially if there's
no way to see what mode you're in. How does the reader of
the output know whether the data was actually positive zero, or
merely that the format was in a mode to supress the sign?

In fact, how does the programmer necessarily tell what mode
is active when writing his IO list? What with reversion and such,
with a large complicated format whings could easily be hard
to see. Maybe if the new descriptors were part of the format
descriptor they applied to? "FZP7.4" for example. This would
not help the person reading the output from the program, but
at least the programmer would know. (One of the known
problems with Fortran is that things like kP descriptors set
modes rather than applying only to a single following format
descriptor.)

--
J. Giles


"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare

John Harper

2006-05-28, 7:06 pm

In article <1148810733.084093.32790@j73g2000cwa.googlegroups.com>,
<robert.corbett@sun.com> wrote:
>I am considering adding some new edit descriptors to Sun f90/f95
>to control the way the signs of floating-point zeros are treated in
>formatted output. The new edit descriptors are: ZP, ZS and ZU.
>The edit descriptor ZP causes floating-point zeros to be
>formatted in the same manner as positive floating-point values,
>regardless of the signs of the zeros. The edit descriptor ZS causes
>negative floating-point zeros to be formatted in the same manner
>as negative values and positive zeros to be formatted in the same
>manner as positive values. The edit descriptor ZU supresses
>production of signs for zeros even when the sign mode is PLUS.

....
>I developed my proposal in response to a request from John Harper.
>My proposal differs completely from what he proposed, but it offers
>the same functionality.


I feel honoured that Bob has improved a suggestion of mine and is
thinking of implementing it. If he does, the experience of Sun and
its users will help get it into f2008 (or f2013?) But I won't use
ZP, ZS, ZU very much until they reach the Fortran standard (or at
least become widely supported extensions) because the best way I know
to catch subtle bugs (whether in my own programs or in compilers)
is to try the same program on various compilers.

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington, New Zealand
e-mail john.harper@vuw.ac.nz phone (+64)(4)463 5341 fax (+64)(4)463 5045


robert.corbett@sun.com

2006-05-29, 4:15 am


Gordon Sande wrote:

> I am not quite clear how ZU above distinguishes between "true zero"
> and "displays as zero". Or is the problem mentioned but not addressed.


For example, the program

PRINT '(SP, ZU, F5.1)', -0.01, -0.0, 0.0, 0.01
END

would write

-0.0
0.0
0.0
+0.0

Bob Corbett

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com