You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
582 B
19 lines
582 B
(defun get-number-at-point () |
|
(interactive) |
|
(skip-chars-backward "0123456789.-") |
|
(or (looking-at "[0123456789.-]+") |
|
(error "No number at point")) |
|
(string-to-number (match-string 0))) |
|
|
|
(defun round-number-at-point-to-decimals (decimal-count) |
|
(interactive "NDecimal count: ") |
|
(let ((mult (expt 10 decimal-count))) |
|
(replace-match (number-to-string |
|
(/ |
|
(fround |
|
(* |
|
mult |
|
(get-number-at-point))) |
|
mult))))) |
|
|
|
(global-set-key (kbd "C-c r") 'round-number-at-point-to-decimals)
|
|
|