help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to check if a string represent an elisp number (including float), w


From: Garreau, Alexandre
Subject: How to check if a string represent an elisp number (including float), without trailing garbage
Date: Tue, 16 Oct 2018 21:38:23 +0200
User-agent: Gnus (5.13), GNU Emacs 25.1.1 (i686-pc-linux-gnu)

`number-to-string' ignores garbage so that falsify the output for any
string beginning with a number but not being one, `cl-parse-integer'
raise an error instead of returning nil, and doesn’t support float,
`read' ignores trailing-garbage.

I’d like something that would work depending on elisp reading of
numbers, not regexps or some redundant specification of it, and
preferably cleaner than “(let ((num (string-to-number str))) (and num
(equal (number-to-string num))))” or anything converting back-and-forth.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]