[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SIGNUM and brain damage



    Date: 22 Oct 84 0042 EDT (Monday)
    From: Guy.Steele@CMU-CS-A.ARPA
    In-Reply-To: "rwg%SPA-NIMBUS@SCRC-STONY-BROOK.ARPA's message of 18 Oct 84 00:49-EST"

    I'm probably guilty here, if guilt there be.  Floating-point contagion
    may have been the disease, but remember also that Common Lisp adopted
    the APL extension to SIGNUM, namely that SIGNUM of a complex number
    returns that point on the unit circle on the ray from the origin to
    the argument (or zero if the argument is zero).  That lent more impetus
    to following the usual contagion rules (both floating and complex).
    It also allows the following fairly elegant definition:
	    (defun signum (x) (if (zerop x) x (/ x (abs x))))
    --Guy

Well, I hardly think invoking divide is elegant, and the complex numbers are
broken without complex infinity, which is phaseless, and must therefore
constitute a fourth value of signum, but that's another story.

A much cruftier corollary of floating contagion shows up in min and max.
It is a contradiction to say "max returns the argument that is greatest ..."
and then in the next sentence say "the implementation is free to produce
... [some rational's] floating point approximation".  Such an approximation
is generally not any of the arguments, or worse, it may even by = to an argument
that was not the largest!