Function: number-at-point

number-at-point is an autoloaded and byte-compiled function defined in thingatpt.el.gz.

Signature

(number-at-point)

Documentation

Return the number at point, or nil if none is found.

Decimal numbers like "14" or "-14.5", as well as hex numbers like "0xBEEF09" or "#xBEEF09", are recognized.

Probably introduced at or before Emacs version 27.1.

Source Code

;; Defined in /usr/src/emacs/lisp/thingatpt.el.gz
;;;###autoload
(defun number-at-point ()
  "Return the number at point, or nil if none is found.
Decimal numbers like \"14\" or \"-14.5\", as well as hex numbers
like \"0xBEEF09\" or \"#xBEEF09\", are recognized."
  (cond
   ((thing-at-point-looking-at thing-at-point-hexadecimal-regexp 500)
    (string-to-number
     (buffer-substring (match-beginning 2) (match-end 2))
     16))
   ((thing-at-point-looking-at thing-at-point-decimal-regexp 500)
    (string-to-number
     (buffer-substring (match-beginning 0) (match-end 0))))))