Function: math-min

math-min is an autoloaded and byte-compiled function defined in calc-arith.el.gz.

Signature

(math-min A B)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-arith.el.gz
;;; Compute the minimum of two real numbers.  [R R R] [Public]
(defun math-min (a b)
  (if (and (consp a) (eq (car a) 'intv))
      (if (and (consp b) (eq (car b) 'intv))
	  (let ((lo (nth 2 a))
		(lom (memq (nth 1 a) '(2 3)))
		(hi (nth 3 a))
		(him (memq (nth 1 a) '(1 3)))
		res)
	    (if (= (setq res (math-compare (nth 2 b) lo)) -1)
		(setq lo (nth 2 b) lom (memq (nth 1 b) '(2 3)))
	      (if (= res 0)
		  (setq lom (or lom (memq (nth 1 b) '(2 3))))))
	    (if (= (setq res (math-compare (nth 3 b) hi)) -1)
		(setq hi (nth 3 b) him (memq (nth 1 b) '(1 3)))
	      (if (= res 0)
		  (setq him (or him (memq (nth 1 b) '(1 3))))))
	    (math-make-intv (+ (if lom 2 0) (if him 1 0)) lo hi))
	(math-min a (list 'intv 3 b b)))
    (if (and (consp b) (eq (car b) 'intv))
	(math-min (list 'intv 3 a a) b)
      (let ((res (math-compare a b)))
	(if (= res 1)
	    b
	  (if (= res 2)
	      '(var nan var-nan)
	    a))))))