> I decided to go with option #1, as this is what C99's
fmin(3)/fmax(3) provides.

OK with me.

> I am reluctant to bother with negative zero - it is an implementation
artifact of IEEE and nonsensical, IMHO. Once you start
adding rules for "consistent" handling of negative zeroes, people
will give it semantic meaning, which I'd rather not encourage.

Two notes:

1. Signed zero already has consistent rules in many other parts of floating-point arithmetic. The biggest example is division, which is in hardware:

    (/ 1.0 -0.0) => -inf.0
    (/ 1.0 +0.0) => +inf.0

Additionally in complex arithmetic, the sign of zero matters when discontinuities occur on the real axis and imaginary axis:

    (angle -1.0+0.0i) => 3.14159...
    (angle -1.0-0.0i) => -3.14159...

2. The rule is there to make max and min commutative over all input values, so permuting -0.0s and +0.0 don't return a different result that then gives the wrong answer later on down the line (like in the previous paragraph).

-- Peter McGoron


Reply via email to