Next: syslib numerics quotient, Previous: syslib numerics lcm, Up: syslib numerics [Index]
These functions perform the integer division between exact and inexact numbers and return two values: the quotient and the remainder. For all the functions: the second argument must be non–zero.
Note that considering:
(quotient+remainder X Y)
according to R6RS:
(define (sign n) (cond ((negative? n) -1) ((positive? n) 1) (else 0))) (define (quotient n1 n2) (* (sign n1) (sign n2) (div (abs n1) (abs n2)))) (define (remainder n1 n2) (* (sign n1) (mod (abs n1) (abs n2)))) (define (modulo n1 n2) (* (sign n2) (mod (* (sign n2) n1) (abs n2))))
so we have:
sign(quotient) = sign(X) * sign(Y) sign(remainder) = sign(X) sign(modulo) = sign(Y)
Perform the integer division between any exact or inexact integer and a fixnum. If num is not an integer: an error is raised. Return exact or inexact integers.
Perform the integer division between any exact or inexact integer and a bignum. If num is not an integer: an error is raised. Return exact or inexact integers.
Perform the integer division between any exact or inexact integer and a flonum. If num is not an integer: an error is raised. Return exact or inexact integers.
Perform the integer division between a fixnum and any exact or inexact integer. If num is not an integer: an error is raised. Return exact or inexact integers.
Perform the integer division between a bignum and any exact or inexact integer. If num is not an integer: an error is raised. Return exact or inexact integers.
Perform the integer division between a flonum and any exact or inexact integer. If num is not an integer: an error is raised. Return exact or inexact integers.
Perform the integer division between a fixnum and a fixnum; return a fixnum or bignum as quotient, return a fixnum as remainder.
Perform the integer division between a fixnum and a bignum; return fixnums.
Perform the integer division between a fixnum and a flonum; return flonums.
Perform the integer division between a bignum and a fixnum; return fixnums.
Perform the integer division between a bignum and a bignum; return fixnums or bignums.
Perform the integer division between a bignum and a flonum; return flonums.
Perform the integer division between a flonum and a fixnum; return flonums.
Perform the integer division between a flonum and a bignum; return flonums.
Perform the integer division between a flonum and a flonum; return flonums.
Next: syslib numerics quotient, Previous: syslib numerics lcm, Up: syslib numerics [Index]