chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] rectnum? misdefined in numbers egg?


From: John Cowan
Subject: [Chicken-users] rectnum? misdefined in numbers egg?
Date: Thu, 25 Jun 2009 15:27:30 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

Normally, a rectnum is understood to be a representation of a non-real
number as two boxes containing arbitrary real numbers, whereas a
compnum uses two unboxed flonums.  However, the numbers egg defines
rectnum? as returning #t if its argument is an exact non-real number.
Consequently, numbers like 1.0+1i are neither rectnums nor compnums.
I think rectnum? should be changed to recognize them as rectnums.

Here are portable implementations of bignum?, flonum?, ratnum?, compnum?,
and rectnum?, given only R5RS and fixnum?:

(define (bignum? x) (and (integer? x) (not (fixnum? x))))

(define (flonum? x) (and (real? x) (inexact? x)))

(define (ratnum? x) (and (exact? x) (not (integer? x))))

(define (compnum? x) (and (not (real? x))
     (let ((re (real-part x))
           (im (imag-part x)))
        (and (inexact? re) (inexact? im)))))

(define (rectnum? x) (and (not (real? x)) (not (compnum? x))))


-- 
The Unicode Standard does not encode            John Cowan
idiosyncratic, personal, novel, or private      http://www.ccil.org/~cowan
use characters, nor does it encode logos
or graphics.                                    address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]