[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
On 12/20/2012 09:53 PM, John Cowan wrote:
> Okay, the details are at ComplexRepresentations now. Racket, Kawa, Chez,
> Vicare, Larceny, Ypsilon, !IronScheme, Spark support (imag-part 2.0) => 0
> even though they don't support mixed-exactness complex numbers.
Kawa supports mixed-exactness complex numbers:
#|kawa:1|# (define z1 (make-rectangular 1.4 2))
#|kawa:2|# (list (real-part z1) (imag-part z1))
(1.4 2)
#|kawa:3|# (list (exact? (real-part z1)) (exact? (imag-part z1)))
(#f #t)
> My guess is that `make-rectangular`
> always returns a boxed or unboxed pair of numbers whatever the values
> may be on every system that supports complex numbers at all.
Not on Kawa:
#|kawa:7|# (eqv? (make-rectangular 1.4 0) 1.4)
#t
#|kawa:8|# (invoke (make-rectangular 1.4 0) 'getClass)
class gnu.math.DFloNum
#|kawa:9|# (invoke (make-rectangular 1.4 0.0) 'getClass)
class gnu.math.DComplex
The abstract class Complex has 3 subclasses:
RealNum - real numbers (an abstract class)
DComplex - a pair of (unboxed) doubles
CComplex - a general pair of (boxed) RealNums
The actual code called by make-rectangular is:
public static Complex make (RealNum re, RealNum im)
{
if (im.isZero() && im.isExact())
return re;
if (! re.isExact() && ! im.isExact())
return new DComplex(re.doubleValue(), im.doubleValue());
return new CComplex (re, im);
}
--
--Per Bothner
per@x http://per.bothner.com/
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports