* moved fxquotient, fxremainder, and fxmodulo to the fixnums library

This commit is contained in:
Abdulaziz Ghuloum 2007-05-05 04:33:58 -04:00
parent bdd87d66b5
commit 6995d57df0
3 changed files with 37 additions and 34 deletions

Binary file not shown.

View File

@ -64,37 +64,6 @@
(set-top-level-value! x v))) (set-top-level-value! x v)))
(primitive-set! 'fxquotient
(lambda (x y)
(unless (fixnum? x)
(error 'fxquotient "~s is not a fixnum" x))
(unless (fixnum? y)
(error 'fxquotient "~s is not a fixnum" y))
(when ($fxzero? y)
(error 'fxquotient "zero dividend ~s" y))
($fxquotient x y)))
(primitive-set! 'fxremainder
(lambda (x y)
(unless (fixnum? x)
(error 'fxremainder "~s is not a fixnum" x))
(unless (fixnum? y)
(error 'fxremainder "~s is not a fixnum" y))
(when ($fxzero? y)
(error 'fxremainder "zero dividend ~s" y))
(let ([q ($fxquotient x y)])
($fx- x ($fx* q y)))))
(primitive-set! 'fxmodulo
(lambda (x y)
(unless (fixnum? x)
(error 'fxmodulo "~s is not a fixnum" x))
(unless (fixnum? y)
(error 'fxmodulo "~s is not a fixnum" y))
(when ($fxzero? y)
(error 'fxmodulo "zero dividend ~s" y))
($fxmodulo x y)))
(primitive-set! 'fxlogor (primitive-set! 'fxlogor
(lambda (x y) (lambda (x y)
(unless (fixnum? x) (unless (fixnum? x)

View File

@ -1,9 +1,12 @@
(library (ikarus fixnums) (library (ikarus fixnums)
(export fxzero? fxadd1 fxsub1 fxlognot fx+ fx- fx*) (export fxzero? fxadd1 fxsub1 fxlognot fx+ fx- fx* fxquotient
fxremainder fxmodulo)
(import (import
(only (scheme) $fxadd1 $fxsub1 $fxlognot $fx+ $fx- $fx*) (only (scheme) $fxadd1 $fxsub1 $fxlognot $fxzero? $fxquotient
(except (ikarus) fxzero? fxadd1 fxsub1 fxlognot fx+ fx- fx*)) $fxmodulo $fx+ $fx- $fx*)
(except (ikarus) fxzero? fxadd1 fxsub1 fxlognot fx+ fx- fx*
fxquotient fxremainder fxmodulo))
(define fxzero? (define fxzero?
(lambda (x) (lambda (x)
@ -54,5 +57,36 @@
(error 'fx* "~s is not a fixnum" y)) (error 'fx* "~s is not a fixnum" y))
($fx* x y))) ($fx* x y)))
(define fxquotient
(lambda (x y)
(unless (fixnum? x)
(error 'fxquotient "~s is not a fixnum" x))
(unless (fixnum? y)
(error 'fxquotient "~s is not a fixnum" y))
(when ($fxzero? y)
(error 'fxquotient "zero dividend ~s" y))
($fxquotient x y)))
(define fxremainder
(lambda (x y)
(unless (fixnum? x)
(error 'fxremainder "~s is not a fixnum" x))
(unless (fixnum? y)
(error 'fxremainder "~s is not a fixnum" y))
(when ($fxzero? y)
(error 'fxremainder "zero dividend ~s" y))
(let ([q ($fxquotient x y)])
($fx- x ($fx* q y)))))
(define fxmodulo
(lambda (x y)
(unless (fixnum? x)
(error 'fxmodulo "~s is not a fixnum" x))
(unless (fixnum? y)
(error 'fxmodulo "~s is not a fixnum" y))
(when ($fxzero? y)
(error 'fxmodulo "zero dividend ~s" y))
($fxmodulo x y)))
) )