Re: On writing negative zero - with or without sign
- From: "James Giles" <jamesgiles@xxxxxxxxxxxxxxxx>
- Date: Thu, 19 Jul 2007 22:26:19 GMT
tholen@xxxxxxxxxxxx wrote:
James Giles writes:....
Maybe I've misunderstood the earlier discussion, but I thought that
minus zero applied only to cases where the actual numerical value
was in fact negative, but the chosen display format was insufficient
to show any significant digits, therefore the number would be
displayed as all zeros, with the question being whether to display
the minus sign or not. For example, should the value -1.2E-5, when
displayed with the format edit descriptor F4.1, be -0.0 or 0.0?
That's easy, the Fortran standard says that a negative value should
have a minus sign output. The earlier discussion was more concerned
over whether an internal value was negative or not, when its magnitude
was zero but it had a set sign bit. The rule should be more clearly
stated in the standard: if the sign bit is set the output should begin
(after any padding blanks) with a minus sign. That's independent of
the magnitude (infact, I think that should be the rule even if the
number turns out to be NaN).
As far as I am concerned, there is only one exact zero, not two, and
not three, and there should be no sign associated with an exact zero.
And, if you're simulating genuine real numbers with your floating
point REAL data type, you'll *never* see something you're sure
is an exact zero.
Suppose you have a record of temperatures recorded at some
observing site and you go through generating a first-difference
(an approximation to a derivative). Well, the thermometer reports
to a tenth of a degree. Suppose two consecutive times show a
value of 15 degrees. That means each value is actually somewhere
between 14.95 and 15.05 degrees and whatever true temp occurred
was rounded to just 15.0 degrees. The float difference of those two
measurements will have a magnitude of zero. But, it's pretty clear
that the temps at the two times were almost certainly more different
than the ~10^(-39) precision of floating point! That zero difference
is hardly *exact* (in fact, the correct answer is in the interval from
-0.1 through 0.1, somewhere). The sign printed with a zero arising
from such a calculation is meaningless, why do you care which is
printed?
In using float to simulate continuous real arithmetic, zeros
can arise a number of ways. They reduce to two categories:
1) underflow, where the sign bit still carries useful (maybe
decisive) information; 2) result of discrete approximation
(like the above difference) where the sign bit means nothing
and a good programmer knows it. There are no third cases,
that is, where it's actually *important* to supress the sign.
Now if you are using floating point to do some kind of discrete
arithmetic rather than as a surrogate for continuous reals, the
sign bit of zero may or may not be important (usually not).
However, I can still see no reason for the implementation
to supress it.
--
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
.
- Follow-Ups:
- Re: On writing negative zero - with or without sign
- From: tholen
- Re: On writing negative zero - with or without sign
- References:
- On writing negative zero - with or without sign
- From: Jerry DeLisle
- Re: On writing negative zero - with or without sign
- From: robert . corbett
- Re: On writing negative zero - with or without sign
- From: Richard Maine
- Re: On writing negative zero - with or without sign
- From: robert . corbett
- Re: On writing negative zero - with or without sign
- From: Richard Maine
- Re: On writing negative zero - with or without sign
- From: Terence
- Re: On writing negative zero - with or without sign
- From: Ron Shepard
- Re: On writing negative zero - with or without sign
- From: James Giles
- Re: On writing negative zero - with or without sign
- From: tholen
- Re: On writing negative zero - with or without sign
- From: James Giles
- Re: On writing negative zero - with or without sign
- From: tholen
- Re: On writing negative zero - with or without sign
- From: James Giles
- Re: On writing negative zero - with or without sign
- From: tholen
- On writing negative zero - with or without sign
- Prev by Date: copyright= C linear dependence testing C no dependence - vectorizable C integer ntimes,ld,n,i,nl real
- Next by Date: Re: On writing negative zero - with or without sign
- Previous by thread: Re: On writing negative zero - with or without sign
- Next by thread: Re: On writing negative zero - with or without sign
- Index(es):
Relevant Pages
|
|