diff --git a/scheme/ikarus.numerics.ss b/scheme/ikarus.numerics.ss index f947186..6bd04ee 100644 --- a/scheme/ikarus.numerics.ss +++ b/scheme/ikarus.numerics.ss @@ -1240,10 +1240,17 @@ [(fixnum? m) (foreign-call "ikrt_bnfx_modulo" n m)] [(bignum? m) - (error 'modulo - "BUG: two bignum arguments are not yet implemented" - n m) - (foreign-call "ikrt_bnbn_modulo" n m)] + (if ($bignum-positive? n) + (if ($bignum-positive? m) + (remainder n m) + (+ m (remainder n m))) + (if ($bignum-positive? m) + (+ m (remainder n m)) + (remainder n m)))] + ;(error 'modulo + ; "BUG: two bignum arguments are not yet implemented" + ; n m) + ;(foreign-call "ikrt_bnbn_modulo" n m)] [(flonum? m) (let ([v ($flonum->exact m)]) (cond diff --git a/scheme/tests/bignums.ss b/scheme/tests/bignums.ss index 3475281..5bb2ec2 100644 --- a/scheme/tests/bignums.ss +++ b/scheme/tests/bignums.ss @@ -82,14 +82,14 @@ [(lambda (x) (= x -116479)) (modulo -536870912238479837489374 -324873)] ; then make both arguments bignums - ;[(lambda (x) (= x 830066489308918857679)) - ; (modulo 536870912238479837489374 3248732398479823749283)] - ;[(lambda (x) (= x 2418665909170904891604)) - ; (modulo -536870912238479837489374 3248732398479823749283)] - ;[(lambda (x) (= x -2418665909170904891604)) - ; (modulo 536870912238479837489374 -3248732398479823749283)] - ;[(lambda (x) (= x -830066489308918857679)) - ; (modulo -536870912238479837489374 -3248732398479823749283)] + [(lambda (x) (= x 830066489308918857679)) + (modulo 536870912238479837489374 3248732398479823749283)] + [(lambda (x) (= x -2418665909170904891604)) + (modulo 536870912238479837489374 -3248732398479823749283)] + [(lambda (x) (= x 2418665909170904891604)) + (modulo -536870912238479837489374 3248732398479823749283)] + [(lambda (x) (= x -830066489308918857679)) + (modulo -536870912238479837489374 -3248732398479823749283)] )) diff --git a/src/ikarus-numerics.c b/src/ikarus-numerics.c index fb98973..12ff1fd 100644 --- a/src/ikarus-numerics.c +++ b/src/ikarus-numerics.c @@ -1464,11 +1464,6 @@ ikrt_bnfx_modulo(ikp x, ikp y, ikpcb* pcb){ } } -ikp -ikrt_bnbn_modulo(ikp x, ikp y, ikpcb* pcb){ - fprintf(stderr, "error in bnbnmodulo\n"); - exit(-1); -}