Function: cl-round
cl-round is an autoloaded and byte-compiled function defined in
cl-extra.el.gz.
Signature
(cl-round X &optional Y)
Documentation
Return a list of X rounded to the nearest integer and the remainder.
With two arguments, return rounding and remainder of their quotient.
Aliases
round* (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-extra.el.gz
;;;###autoload
(defun cl-round (x &optional y)
"Return a list of X rounded to the nearest integer and the remainder.
With two arguments, return rounding and remainder of their quotient."
(declare (side-effect-free t))
(if y
(if (and (integerp x) (integerp y))
(let* ((hy (/ y 2))
(res (cl-floor (+ x hy) y)))
(if (and (= (car (cdr res)) 0)
(= (+ hy hy) y)
(oddp (car res)))
(list (1- (car res)) hy)
(list (car res) (- (car (cdr res)) hy))))
(let ((q (round (/ x y))))
(list q (- x (* q y)))))
(if (integerp x) (list x 0)
(let ((q (round x)))
(list q (- x q))))))