Re: On writing negative zero - with or without sign



James Giles writes:

....

Why should the sign bit be set if the magnitude is zero?

It's often decisive information. It's up to th euser to know if it
matters - it's *NOT* up to the implementation to arbitrarily decide
for the user. If it worries you, be content that I don't know any
implementations that set the sign bit for zeros that result from
sums or differences. The IEEE standard allows either sign
in such a case. For underflow the sign almost always carries
useful information. The implementation should never supress
it.

But

Z = (Y - X)/A

and

Z = Y/A - X/A

are algebraically equivalent. Suppose (Y - X)/A underflows, but
neither Y/A or X/A underflows, and the sign bit wouldn't be set
for the difference.

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.

Why not? Suppose I difference two real numbers that have the exact
same internal representation.

Then the *actual* difference is approximately the same magnitude
as the error in the least accurately calculated of the two operands.
For nearly all calculations that's a lots bigger than zero.

You're assuming that the numbers are calculated. I had previously
given an example in which the numbers being differenced were
assigned, not calculated (or manipulated, to use my previous term).

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?

You're assuming that I would want one or the other printed. In such
a case, I would be content to have no sign. It's up to the user to
properly interpret the results of a calculation.

And it's not up to the implementation to make that decision for
him(her). If it's up to the user, leave the sign there and let
the user decide. Never lie to the user.

Suppose in your temperature example, the first value was really
15.01 and the second value was 14.99, but the implementation
couldn't know that and used a plus sign, thus lying to the user.
Indeed, if forced to display a sign in that example, there's a
fifty percent chance of lying to the user.

If the sign bit carries decisive information, then it's important
for the correct sign to be displayed. In your temperature example
above, you noted that the correct answer could be either positive
or negative, so there is no way for the processor to know which is
the correct sign, thus I would argue it's important to suppress the
sign.

But, an absent sign *means* positive zero!

I disagree.

Supressing it has no advantages. It helps no one.

Again, I disagree. See above for an example.

.



Relevant Pages

  • Re: Product Calculation in an Access Query
    ... If "value" contains only positive numbers(no nulls, no negatives, no zero ... how do I do this calculation in Access? ... VLDT, Index Code, Index Name and Return. ... it doesn't appear that there is a product function in access. ...
    (microsoft.public.access.queries)
  • Re: Does DateDiff Have A Bug
    ... Now I just use the results from the query and everything works better than ... MemberID FirstName LastName EntryDate DaysRemaining ... calculated field within it's calculation) would look like; ... if there are zero days left which in ...
    (microsoft.public.access.formscoding)
  • Re: Does DateDiff Have A Bug
    ... Now you would go to Queries/Create query in Design View, ... MemberID FirstName LastName EntryDate DaysRemaining ... calculated field within it's calculation) would look like; ... I'm trying to write the result of lngDays when it reaches zero days ...
    (microsoft.public.access.formscoding)
  • Re: Does DateDiff Have A Bug
    ... Now you would go to Queries/Create query in Design View, ... MemberID FirstName LastName EntryDate DaysRemaining ... calculated field within it's calculation) would look like; ... I'm trying to write the result of lngDays when it reaches zero days ...
    (microsoft.public.access.formscoding)
  • Re: How do I replace error messages in Access?
    ... It would help if you posted the calculation you are using. ... Of course if you always wanted to return 1 when SomeNumber was zero, ... In my reports I often have to calculate the ... only if users update the field. ...
    (microsoft.public.access.queries)