From: Paul F. Dietz <dietz@dl...> - 2003-09-07 12:57:36
According to CLtS (page for REALPART, IMAGPART):
realpart and imagpart return the real and imaginary parts of number
respectively. If number is real, then realpart returns number and
imagpart returns (* 0 number), which has the effect that the imaginary
part of a rational is 0 and that of a float is a floating-point zero
of the same format.
(* 0 -1.0) ==> -0.0
(imagpart -1.0) ==> 0.0
This occurs in both sbcl and cmucl (x86/linux).
From: Paul Dietz <paul.dietz@mo...> - 2003-09-09 15:47:59
Gerd Moellmann wrote:
> Maybe there's an inconsistency in the standard? The description of
> COMPLEX says
> If imagpart is not supplied, the imaginary part is a zero of the
> same type as realpart; i.e., (coerce 0 (type-of realpart)) is
> effectively used.
> Wouldn't it be quite surprising if
> (imagpart -1.0)
> => -0.0
> (imagpart (complex -1.0))
> => 0.0
Perhaps. I'll also note that the sentence from COMPLEX adds
another constraint to TYPE-OF and COERCE: the type returned
(for REALS) must contain zero, and must be an admissable second
argument to COERCE.