* Added fleven? and flodd?

This commit is contained in:
Abdulaziz Ghuloum 2007-09-10 22:45:41 -04:00
parent fa63e8723c
commit cb94cf88b2
4 changed files with 30 additions and 6 deletions

Binary file not shown.

View File

@ -9,15 +9,16 @@
(export $flonum->exact $flonum-signed-biased-exponent flonum-parts
inexact->exact exact $flonum-rational? $flonum-integer? $flzero?
$flnegative? flpositive? flabs fixnum->flonum
flsin flcos fltan flasin flacos flatan
flsin flcos fltan flasin flacos flatan fleven? flodd?
flinteger? flonum-bytes flnan? flfinite? flinfinite?)
(import
(ikarus system $bytevectors)
(only (ikarus system $fx) $fxzero? $fxlogand)
(ikarus system $fx)
(ikarus system $bignums)
(except (ikarus system $flonums) $flonum-signed-biased-exponent
$flonum-rational? $flonum-integer?)
(except (ikarus) inexact->exact exact flpositive? flabs
fixnum->flonum flsin flcos fltan flasin flacos flatan
(except (ikarus) inexact->exact exact flpositive? flabs fixnum->flonum
flsin flcos fltan flasin flacos flatan fleven? flodd?
flinteger? flonum-parts flonum-bytes flnan? flfinite? flinfinite?))
(define (flonum-bytes f)
@ -87,6 +88,27 @@
(let ([v ($flonum->exact x)])
(or (fixnum? v) (bignum? v)))])))
(define (fleven? x)
(unless (flonum? x)
(error 'fleven? "~s is not a flonum" x))
(let ([v ($flonum->exact x)])
(cond
[(fixnum? v) ($fx= ($fxlogand v 1) 0)]
[(bignum? v)
(foreign-call "ikrt_even_bn" v)]
[else (error 'fleven? "~s is not an integer flonum" x)])))
(define (flodd? x)
(unless (flonum? x)
(error 'flodd? "~s is not a flonum" x))
(let ([v ($flonum->exact x)])
(cond
[(fixnum? v) ($fx= ($fxlogand v 1) 1)]
[(bignum? v)
(not (foreign-call "ikrt_even_bn" v))]
[else (error 'flodd? "~s is not an integer flonum" x)])))
(define (flinteger? x)
(if (flonum? x)
($flonum-integer? x)

View File

@ -506,6 +506,8 @@
[flfinite? i]
[flinfinite? i]
[flnan? i]
[fleven? i]
[flodd? i]
[exact? i r]
[inexact? i r]
[rational? i r]

View File

@ -319,7 +319,7 @@
[fldiv-and-mod S fl]
[fldiv0 S fl]
[fldiv0-and-mod0 S fl]
[fleven? S fl]
[fleven? C fl]
[flexp S fl]
[flexpt S fl]
[flfinite? C fl]
@ -334,7 +334,7 @@
[flnan? C fl]
[flnegative? C fl]
[flnumerator S fl]
[flodd? S fl]
[flodd? C fl]
[flonum? C fl]
[flpositive? C fl]
[flround C fl]