Up: Floating Point Efficiency   [Contents][Index]


5.11.7.1 Signed Zeroes and Special Functions

CMUCL supports IEEE signed zeroes. In typical usage, the signed zeroes are not a problem and can be treated as an unsigned zero. However, some of the special functions have branch points at zero, so care must be taken.

For example, suppose we have the function

  (defun fun (x)
    (declare (type (single-float 0f0) x))
    (log x))

The derived result of the function is (OR SINGLE-FLOAT (COMPLEX SINGLE-FLOAT)) because the declared values for x includes both -0.0 and 0.0 and (log -0.0) is actually a complex number. Because of this, the generic complex log routine is used.

If the declaration for x were (single-float (0f0)) so +0.0 is not included or (or (single-float (0f0)) (member 0f0)) so +0.0 is include but not -0.0, the derived type would be single-float for both cases. By declaring x this way, the log can be implemented using a fast real-valued log routine instead of the generic log routine.

CMUCL implements the branch cuts and values given by Kahan14.


Footnotes

(14)

Kahan, W., “Branch Cuts for Complex Elementary Functions, or Much Ado About Nothing’s Sign Bit” in Iserles and Powell (eds.) The State of the Art in Numerical Analysis, pp. 165-211, Clarendon Press, 1987


Up: Floating Point Efficiency   [Contents][Index]