Function: calculator-standard-displayer
calculator-standard-displayer is a byte-compiled function defined in
calculator.el.gz.
Signature
(calculator-standard-displayer NUM &optional CHAR GROUP-P)
Documentation
Standard display function, used to display NUM.
Its behavior is determined by calculator-number-digits and the given
CHAR argument (both will be used to compose a format string). If the
char is "n" then this function will choose one between %f or %e, this
is a work around %g jumping to exponential notation too fast.
It will also split digit sequences into comma-separated groups and/or remove redundant zeros.
The special left and right symbols will make it change the current
number of digits displayed (calculator-number-digits).
Source Code
;; Defined in /usr/src/emacs/lisp/calculator.el.gz
(defun calculator-standard-displayer (num &optional char group-p)
"Standard display function, used to display NUM.
Its behavior is determined by `calculator-number-digits' and the given
CHAR argument (both will be used to compose a format string). If the
char is \"n\" then this function will choose one between %f or %e, this
is a work around %g jumping to exponential notation too fast.
It will also split digit sequences into comma-separated groups
and/or remove redundant zeros.
The special `left' and `right' symbols will make it change the current
number of digits displayed (`calculator-number-digits')."
(if (symbolp num)
(cond ((eq num 'left)
(when (> calculator-number-digits 0)
(setq calculator-number-digits
(1- calculator-number-digits))
(calculator-enter)))
((eq num 'right)
(setq calculator-number-digits
(1+ calculator-number-digits))
(calculator-enter)))
(let* ((s (if (eq char ?n)
(let ((n (abs num)))
(if (or (and (< 0 n) (< n 0.001)) (< 1e8 n)) ?e ?f))
char))
(s (format "%%.%s%c" calculator-number-digits s))
(s (calculator-remove-zeros (format s num)))
(s (if (or (not group-p) (string-match-p "[eE]" s)) s
(replace-regexp-in-string
"\\([0-9]+\\)\\(?:\\..*\\|$\\)"
(lambda (_) (calculator-groupize-number
(match-string 1 s) 3 ","))
s nil nil 1))))
s)))