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

Re: [Scheme-reports] Strong win later reversed: Real numbers have imaginary part #e0



John Cowan <cowan@x> writes:

> Mark H Weaver scripsit:
>
>> There are several other ways of checking for this, such as:
>> 
>>   (eqv? 1.0+0.0i 1.0+0i)
>> 
>> and
>> 
>>   (eqv? (make-rectangular 1.0 0.0)
>>         (make-rectangular 1.0 0))
>> 
>> For the three implementations I mentioned (Guile 2, Racket, and Ikarus)
>> the expressions above return #f.
>
> Those are also consistent with (make-rectangular x 0) simply returning
> a flonum.

Who cares?  The number of fields used internally to represent 1.0+0.0i
or 1+0i has no relevance to the user or to the Scheme standards.  As you
know, reals are a subset of the complex numbers, and thus flonums count
as a representation of complex numbers.

My point is that your ComplexRepresentation page states that Guile and
Racket do not support complex numbers of mixed exactness, but that's not
quite true.  There is one important special case of mixed exactness that
*is* supported in Guile, Racket, Ikarus, and perhaps others.

> I tried the 45 Schemes (less those with no make-rectangular support) with
> this expression:
>
> (let
>   ((m (make-rectangular 2.0 2))
>    (z (make-rectangular 2.0 0)))
>      (list m z (real? m) (real? z)))
>
> All the Schemes, except those which don't support make-rectangular, replied
> either (2.0+2i 2.0 #f #t) or (2.0+2.0i 2.0 #f #t),

I really don't see any point to this test that you did.  Of course, in
any implementation that is not utterly broken, (make-rectangular 2.0 0)
is 'real?' and (make-rectangular 2.0 2) is not.

If you had run one of the tests I gave above, then we might have learned
something to help improve your ComplexRepresentations page.

Another test that would be worthwhile is this:

  (list (eqv? +0.0 -0.0)
        (eqv? (make-rectangular +0.0  1.0)
              (make-rectangular -0.0  1.0))
        (eqv? (make-rectangular  1.0 +0.0)
              (make-rectangular  1.0 -0.0))

I wouldn't be surprised if some Schemes distinguish signed zeroes in the
real part but not in the imaginary part.  If an implementation discards
inexact zero imaginary parts, then it probably discards the sign as well
as the exactness.

     Mark

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports