[gnu.emacs.bug] Patch for safe-idiv

macrakis@marat.osf.fr (Stavros Macrakis) (12/29/89)

GNU Emacs 18.55.1 of Tue Oct 31 1989 on marat (hpux)

The following patch fixes the mod bug I reported yesterday:

        --- in cl.el ---

(defun safe-idiv (a b)
  "SAFE-IDIV A B => Q R S
Q=|A|/|B|, R is the rest, S is the sign of A/B."
  (unless (and (numberp a) (numberp b))
    (error "Arguments to `safe-idiv' must be numbers"))
  (when (zerop b)
    (error "Cannot divide %d by zero" a))
  (let* ((absa (abs a))
         (absb (abs b))
         (q    (/ absa absb))
;        (s    (signum (* a b)))		;; Can overflow
	 (s    (* (signum a) (signum b)))	;; Can't overflow
         (r    (- a (* (* s q) b))))
    (values q r s)))