[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
Reproducibility of minNum() and maxNum() for decimal
Well, not just for decimal...
Several people have pointed out that this issue arises for signed zeros
too, so that the predicate (1/minNum(-0,+0) < 1/minNum(+0,-0)) could
be used to tell whether minNum() picks the first or the second operand
for equal values (assuming non-equality, as equality of the two Infs
would suggest an implementation that uses totalOrder() for tiebreaking).
It seems however that people are concerned more about commutativity
than definiteness, and would not care for my suggestion of requiring
that the first of two numerically-equal operands be returned.
Many people prefer tie-breaking via totalOrder so as to preserve the
commutativity of the operation -- but totalOrder is an expensive
operation, and even detecting the need for tiebreaking may introduce
an additional branch in a macro implementation.
Recommending the use of totalOrder() to avoid the indefiniteness of
minNum etc. is not helpful in the context of Clause 11 reproducibility
because totalOrder() is itself indefinite in that context, because it
reacts to the sign of NaNs. I suppose encapsulated use (just for the
purpose of breaking minNum() ties) would be ok.
Btw, I was not concerned so much about hardware min/max instructions,
but about the common practice of encapsulating min/max in macros that
use comparison under the cover -- and in that case requiring asymmetric
tiebreaking (e.g. pick first operand) would not increase the cost.
It seems that the cheapest solution (from the point of view of ensuring
consistency of the 754R standard) might be to move these operations to
Clause 9 (but with a requirement to be present, unlike other Clause 9
operations which are in fact optional), as Mike recommended. I'm not
entirely happy about that; I think they should be first-class operations.
Michel.
P.S. Note that there is precedent for breaking commutativity, when
NaNs are involved. I'm aware that this is at a different level.
Sent: 2008-03-16 15:49:34 UTC