GNU bug report logs -
#48678
[PATCH] lex floats with trailing dot and exponent correctly
Previous Next
Reported by: Mattias EngdegÄrd <mattiase <at> acm.org>
Date: Wed, 26 May 2021 16:57:02 UTC
Severity: normal
Tags: fixed, patch
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Motivation: I poured lots of numeric data into Emacs for a computation, but the result weren't as expected at all. Yet my code was correct, and so was the data.
After hours of debugging, it turned out that Emacs reads a number like 1.e6 as the integer 1, not the float 1000000.0. The exponent is silently ignored!
Now Emacs has always treated numbers like 123. as integers rather than floats, but
(1) it's documented,
(2) it's what Common Lisp does, and
(3) it actually doesn't affect the numeric value most of the time.
(Common Lisp probably got this from Maclisp, the rationale being that a trailing dot can be used to write integers in base 10 even when the current input radix is set to something else, something that Emacs Lisp doesn't need.)
Obviously this doesn't apply to 1.e6 which any sane person agrees is the float 1.0e+6 (including Common Lisp).
The attached patch fixes this bug.
[0001-Fix-lexing-of-numbers-with-trailing-decimal-point-an.patch (application/octet-stream, attachment)]
This bug report was last modified 3 years and 353 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.