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

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Mon Jun 4 18:43:25 EDT 2007

Matthew Flatt skrev:
> At Mon, 04 Jun 2007 17:03:06 -0500, Chongkai Zhu wrote:
>> Yes, my `0-imag-part?' fails for some cases.
> 
> Which cases?
> 
>> Jens Axel Søgaard wrote:
>>> The problem is that 3.0 and 3.0+0.0i is the same number.
>>> The real part and the imaginary part shares the exactness.
> 
> No, they're different:
> 
>  > (eqv? 3.0 3.0+0.0i)
>  #f

That's odd.

 From R5RS section 6.1:

   The eqv? procedure returns #t if:

     * obj1 and obj2 are both numbers, are numerically equal (see =,
       section 6.2), and are either both exact or both inexact.


   > (= 3.0 3.0+0.0i)
   #t

   > (inexact? 3.0)
   #t

   > (inexact? 3.0+0.0i)
   #t

-- 
Jens Axel Søgaard



Posted on the users mailing list.