[plt-scheme] Re: Test a numbers representation to see if it's complex?

From: Ryan R Newton (newton at MIT.EDU)
Date: Tue Jun 5 16:05:21 EDT 2007

Well, sorry to answer my own question, but someone on IRC pointed out that the
imaginary component of (inexact) reals is still an exact zero.  Which allows me
to do this:

  (define (cflonum? n) (and (number? n) (inexact? n) (not (eqv? 0 (imag-part

On Jun 4, 2007, at 5:14 PM, Ryan Newton wrote:

Yes, this is not normally a nice thing to do.  But I have a need to
distinguish 3.0 and 3.0+0.0i.  As far as I can tell, while PLT *could*
turn 3.0+0.0i into 3.0, but for whatever reason the complex
representation seems closed under PLT's arithmetic, which makes what I
want to do somewhat sane.

(For reference, I'm embedding a statically typed language in Scheme,
and I would like to sanity check the object representations


Posted on the users mailing list.