The 2007 update of 10967 is somewhat more helpful. It replaces the
"sign" operation with one called "signum" which returns 1, -1, or NaN.
It returns 1 for positive zero and positive infinity, and -1 for
negative zero and negative infinity. If given a qNaN, it returns a qNaN.
If given a signaling NaN, it returns a qNaN but notifies the application
of an "invalid" situation.

That's ISO 10967. However, IEEE-758-2008 specifies implementations shall provide isSignMinus(x). This operation is true if and only if x has negative sign, and applies to zeros and NaNs.

IMO, values that operate according to IEEE-758-2008 should behave as specified by IEEE-758-2008 by default. The ISO 10967 standard seems more of a layer on top of things like IEEE-758-2008, because it's a standard for language agnostic arithmetic.

So, shouldn't #sign behave as in IEEE-758-2008?

        ^self isSignMinus ifTrue: [-1] ifFalse: [1]

It looks like the real question is whether Float's methods are merely renaming IEEE-758-2008 functionality (if yes, why rename at all and add to the confusion?), ISO 10967 functionality, or are something else entirely (e.g. Smalltalk provided behavior in the context of the Smalltalk experience).

For example, does it make sense -0.0 < 0.0 to answer false (because zeros must be numerically equivalent) while -0.0 ~= 0.0 sign answers true? That depends on where #sign belongs to. This is very important because if #sign isn't IEEE-758 or ISO 10967, then why use it or care about how it behaves? And if there's no good explanation, then why is #sign there in the first place?

Andres.

Reply via email to