Common Lisp the Language, 2nd Edition


next up previous contents index
Next: Exponential and Logarithmic Up: Numbers Previous: Arithmetic Operations

12.5. Irrational and Transcendental Functions

Common Lisp provides no data type that can accurately represent irrational numerical values. The functions in this section are described as if the results were mathematically accurate, but actually they all produce floating-point approximations to the true mathematical result in the general case. In some places mathematical identities are set forth that are intended to elucidate the meanings of the functions; however, two mathematically identical expressions may be computationally different because of errors inherent in the floating-point approximation process.

When the arguments to a function in this section are all rational and the true mathematical result is also (mathematically) rational, then unless otherwise noted an implementation is free to return either an accurate result of type rational or a single-precision floating-point approximation. If the arguments are all rational but the result cannot be expressed as a rational number, then a single-precision floating-point approximation is always returned.

change_begin
X3J13 voted in March 1989 (COMPLEX-RATIONAL-RESULT)   to clarify that the provisions of the previous paragraph apply to complex numbers. If the arguments to a function are all of type (or rational (complex rational)) and the true mathematical result is (mathematically) a complex number with rational real and imaginary parts, then unless otherwise noted an implementation is free to return either an accurate result of type (or rational (complex rational)) or a single-precision floating-point approximation of type single-float (permissible only if the imaginary part of the true mathematical result is zero) or (complex single-float). If the arguments are all of type (or rational (complex rational)) but the result cannot be expressed as a rational or complex rational number, then the returned value will be of type single-float (permissible only if the imaginary part of the true mathematical result is zero) or (complex single-float).
change_end

The rules of floating-point contagion and complex contagion are effectively obeyed by all the functions in this section except expt, which treats some cases of rational exponents specially. When, possibly after contagious conversion, all of the arguments are of the same floating-point or complex floating-point type, then the result will be of that same type unless otherwise noted.


Implementation note: There is a ``floating-point cookbook'' by Cody and Waite [14] that may be a useful aid in implementing the functions defined in this section.




next up previous contents index
Next: Exponential and Logarithmic Up: Numbers Previous: Arithmetic Operations


AI.Repository@cs.cmu.edu