Re: On writing negative zero - with or without sign



tholen@xxxxxxxxxxxx wrote:
James Giles writes:
....
It certainly can represent zero: as one of many possible values
of an approximation that includes zero. If that's your definition
of representing an "exact" zero...

My definition of an "exact" zero is whatever internal representation
is used when two identical internal representations are differenced.

Ok, but there are two such numbers. Minus zero and plus zero are
both allowed as results of that operation. Which of those is "exact"
zero? They both compare equal to plus zero (they both compare
equal to minus zero). This all disregards the known property that
differences of nearly identical (or, in this case, identical) values
leaves little or no significance in the result (at least assuming the
numbers being subtracted are the result of prior calculation).
Again I point out that things like interval arithmetic were indended
to address this property.

....

REAL X,Y
LOGICAL L

X = 1.0
Y = SQRT(X*X)
L = X == Y
....
What about the reverse case:

Y = (SQRT(X))**2


The set of values for which L will be .TRUE. for that changed
expression is different, but there are numbers (1.0 included)
for which I would expect .TRUE. regardless of rounding mode.
The set is somewhat smaller than for the original example.
And of course Fortran can still see the identity that SQRT(X)**2
is X. (Some people have disputed whether Fortran is permitted
to disregard the fact that negative values of X are invalid in
the original expression. I won't debate it here.)

--
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


.



Relevant Pages

  • Re: On writing negative zero - with or without sign
    ... exact zero, contrary to your claim that there is no such thing. ... And I noted that there is a subset of continuous reals that can be ... representation to account for "actual zero"). ...
    (comp.lang.fortran)
  • Re: On writing negative zero - with or without sign
    ... I responded to the issue of an "exact" zero. ... that doesn't mean I believe the thermometer example represents a ... Propagate the quantization error of 0.1 degrees. ...
    (comp.lang.fortran)
  • Re: On writing negative zero - with or without sign
    ... can represent, manipulate, or produce metaphysically perfect ... I sure hope that a program can represent an exact zero. ... Presumably X and Y have the exact same internal representation, ...
    (comp.lang.fortran)
  • Re: On writing negative zero - with or without sign
    ... exact zero, contrary to your claim that there is no such thing. ... that using float for something *other* than simulating continuous reals ... "exactitude" in general, but rather a very specific issue, namely ...
    (comp.lang.fortran)
  • Re: On writing negative zero - with or without sign
    ... of representing an "exact" zero... ... My definition of an "exact" zero is whatever internal representation ... *only* value associated with that approximation. ... A subset of floating point numbers can have an exact representation. ...
    (comp.lang.fortran)