[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sqrt(-1)
- To: fateman%UCBKIM@UCB-VAX (Richard Fateman)
- Subject: Re: sqrt(-1)
- From: Guy.Steele@CMU-CS-A
- Date: Tue, 07 Jun 1983 03:09:00 -0000
- Cc: common-lisp@SU-AI
- In-reply-to: <8306062018.8926@UCBKIM.ARPA>
(1+ fixnum) IS NOT NECESSARILY a fixnum in Common LISP. It is fairly important
to the user that it not be.
I'm reminded of Tom Lehrer's remark in his introduction to "New Math"
on his album "That Was the Year That Was": "In the New Math, on the other
hand, the *idea* is the important thing... *rather* than getting the right
answer."
If you're worried about the speed of code, then there are several ways
to use declarations to say what you mean:
(THE DOUBLE-FLOAT (SQRT D))
(SQRT (THE (SINGLE-FLOAT 0.0 ()) D))
for example. (The first guarantees the result of SQRT to be a double-float;
the second guarantees the argument to be a non-negative single-float.)
One can also use assertions if explicit run-time checking is desired.
Perhaps, Dick, you have failed to realize that it is proposed to treat
rational and floating-point complex numbers according to different rules.
With rationals, as with integers (fixnums plus bignums) in MacLISP,
the emphasis is on getting the one, true, mathematically correct answer,
no matter what it takes. With floating-point, the emphasis is on sacrificing
accuracy for speed (as well as finiteness of representation, as necessary
in the case of irrational computations), *but* on sacrificing that accuracy
in a predictable and controllable fashion. Common LISP's treatment of
floating-point is essentially the traditional one. Automatic coercion
is provided in the form of floating-point contagion rules, but these are
never used in the case where one writes Common LISP code in as type-stringent
a manner as one would be compelled to in a strongly-typed language such
as FORTRAN. In the absence of such contagion, Common LISP's treatment
of floating-point is entirely consistent with the usual usage, and in
particular is completely consistent with the proposed IEEE floating-point
standard.
--Guy
- References:
- Re: sqrt(-1)
- From: fateman%UCBKIM@Berkeley (Richard Fateman)