diff --git a/src/ikarus.boot b/src/ikarus.boot index ba0d8f9..a77751f 100644 Binary files a/src/ikarus.boot and b/src/ikarus.boot differ diff --git a/src/ikarus.core.ss b/src/ikarus.core.ss index c38a74b..8aca270 100644 --- a/src/ikarus.core.ss +++ b/src/ikarus.core.ss @@ -64,37 +64,6 @@ (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 (lambda (x y) (unless (fixnum? x) diff --git a/src/ikarus.fixnums.ss b/src/ikarus.fixnums.ss index 82079fb..74629d5 100644 --- a/src/ikarus.fixnums.ss +++ b/src/ikarus.fixnums.ss @@ -1,9 +1,12 @@ (library (ikarus fixnums) - (export fxzero? fxadd1 fxsub1 fxlognot fx+ fx- fx*) + (export fxzero? fxadd1 fxsub1 fxlognot fx+ fx- fx* fxquotient + fxremainder fxmodulo) (import - (only (scheme) $fxadd1 $fxsub1 $fxlognot $fx+ $fx- $fx*) - (except (ikarus) fxzero? fxadd1 fxsub1 fxlognot fx+ fx- fx*)) + (only (scheme) $fxadd1 $fxsub1 $fxlognot $fxzero? $fxquotient + $fxmodulo $fx+ $fx- $fx*) + (except (ikarus) fxzero? fxadd1 fxsub1 fxlognot fx+ fx- fx* + fxquotient fxremainder fxmodulo)) (define fxzero? (lambda (x) @@ -54,5 +57,36 @@ (error 'fx* "~s is not a fixnum" 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))) + )