(values (+ q 1) (- x (* (+ q 1) y))))
(else
(values (- q 1) (- x (* (- q 1) y)))))))
-
-(define (euclidean/ n d)
- (if (and (exact-integer? n) (exact-integer? d))
- (cond ((and (negative? n) (negative? d))
- (ceiling-/- n d))
- ((negative? n)
- (floor-/+ n d))
- ((negative? d)
- (let ((d (- 0 d)))
- (values (- 0 (quotient n d))
- (remainder n d))))
- (else
- (values (quotient n d)
- (remainder n d))))
- (let ((q
- (if (negative? d)
- (ceiling (/ n d))
- (floor (/ n d)))))
- (values q (- n (* d q))))))
-
-(define (floor-/+ n d)
- (let ((n (- 0 n)))
- (let ((q (quotient n d))
- (r (remainder n d)))
- (if (zero? r)
- (values (- 0 q) r)
- (values (- (- 0 q) 1) (- d r))))))
-
-(define (ceiling-/- n d)
- (let ((n (- 0 n)) (d (- 0 d)))
- (let ((q (quotient n d))
- (r (remainder n d)))
- (if (zero? r)
- (values q r)
- (values (+ q 1) (- d r))))))
\f
(define (fxif mask i j)
(fxior (fxand mask i)