Function: math-binary-modulo-args

math-binary-modulo-args is a byte-compiled function defined in calc-bin.el.gz.

Signature

(math-binary-modulo-args F A B W)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-bin.el.gz
(defun math-binary-modulo-args (f a b w)
  (let (mod)
    (if (eq (car-safe a) 'mod)
	(progn
	  (setq mod (nth 2 a)
		a (nth 1 a))
	  (if (eq (car-safe b) 'mod)
	      (if (equal mod (nth 2 b))
		  (setq b (nth 1 b))
		(math-reject-arg b "*Inconsistent modulus"))))
      (setq mod (nth 2 b)
	    b (nth 1 b)))
    (if (Math-messy-integerp mod)
	(setq mod (math-trunc mod))
      (or (Math-integerp mod)
	  (math-reject-arg mod 'integerp)))
    (let ((bits (math-integer-log2 mod)))
      (if bits
	  (if w
	      (if (and (/= w bits) (not (zerop w)))
		  (calc-record-why
		   "*Warning: Modulus inconsistent with word size"))
	    (setq w bits))
	(calc-record-why "*Warning: Modulus is not a power of 2"))
      (math-make-mod (if b
			 (funcall f a b w)
		       (funcall f a w))
		     mod))))