Article View: gnu.emacs.bug
Article #1800Patch for safe-idiv
From: Stavros Macrakis
Date: Thu, 28 Dec 1989 18:48
Date: Thu, 28 Dec 1989 18:48
20 lines
1037 bytes
1037 bytes
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)))
Technical Details
Message-ID:
<8912281048.AA00519@mururoa.imag.fr>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!marat.osf.fr!macrakisShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!marat.osf.fr!macrakis From: macrakis@marat.osf.fr (Stavros Macrakis) Newsgroups: gnu.emacs.bug Subject: Patch for safe-idiv Message-ID: <8912281048.AA00519@mururoa.imag.fr> Date: 28 Dec 89 18:48:25 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 20