[latex3-commits] [git/LaTeX3-latex3-latex3] master: Recognize uppercase E as an exponent marker in l3fp (like lowercase e) (05804dcc8)

Bruno Le Floch bruno at le-floch.fr
Sat Apr 18 21:50:23 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/05804dcc8d8e3546371ed51afdaa72e9292d9c16

>---------------------------------------------------------------

commit 05804dcc8d8e3546371ed51afdaa72e9292d9c16
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Sat Apr 18 21:50:23 2020 +0200

    Recognize uppercase E as an exponent marker in l3fp (like lowercase e)
    
    See https://tex.stackexchange.com/questions/538710


>---------------------------------------------------------------

05804dcc8d8e3546371ed51afdaa72e9292d9c16
 l3kernel/CHANGELOG.md                | 3 +++
 l3kernel/l3fp-parse.dtx              | 6 +++---
 l3kernel/l3fp.dtx                    | 4 ++--
 l3kernel/testfiles/m3fp-parse001.lvt | 8 ++++++++
 l3kernel/testfiles/m3fp-parse001.tlg | 6 ++++++
 5 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 59f598080..7908779c2 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Added
+- Recognize the exponent marker `E` (same as `e`) in floating point numbers
+
 ## [2020-04-06]
 
 ### Added
diff --git a/l3kernel/l3fp-parse.dtx b/l3kernel/l3fp-parse.dtx
index e69b63ba0..f338f9473 100644
--- a/l3kernel/l3fp-parse.dtx
+++ b/l3kernel/l3fp-parse.dtx
@@ -1647,8 +1647,8 @@
 %   This function should be called within an \cs{int_value:w}
 %   expansion (or within an integer expression).  It leaves digits of the
 %   exponent behind it in the input stream, and terminates the expansion
-%   with a semicolon.  If there is no~|e|, leave an exponent of~$0$.  If
-%   there is an~|e|, expand the next token to run some tests on it.  The
+%   with a semicolon.  If there is no~|e| (or~|E|), leave an exponent of~$0$.  If
+%   there is an~|e| or~|E|, expand the next token to run some tests on it.  The
 %   first rough test is that if the character code of~|#1| is greater
 %   than that of~|9| (largest code valid for an exponent, less than any
 %   code valid for an identifier), there was in fact no exponent;
@@ -1656,7 +1656,7 @@
 %    \begin{macrocode}
 \cs_new:Npn \@@_parse_exponent:N #1
   {
-    \if:w e \exp_not:N #1
+    \if:w e \if:w E \exp_not:N #1 e \else: \exp_not:N #1 \fi:
       \exp_after:wN \@@_parse_exponent_aux:N
       \exp:w
     \else:
diff --git a/l3kernel/l3fp.dtx b/l3kernel/l3fp.dtx
index 73aa3db9d..b341ad05d 100644
--- a/l3kernel/l3fp.dtx
+++ b/l3kernel/l3fp.dtx
@@ -813,7 +813,7 @@
 %   \item \meta{sign}: a possibly empty string of |+| and |-| characters;
 %   \item \meta{significand}: a non-empty string of digits together with zero
 %     or one dot;
-%   \item \meta{exponent} optionally: the character |e|, followed by a
+%   \item \meta{exponent} optionally: the character |e| or |E|, followed by a
 %     possibly empty string of |+|~and~|-| tokens, and a non-empty string
 %     of digits.
 % \end{itemize}
@@ -843,7 +843,7 @@
 % valid floating point numbers.  Note that the latter could be mistaken
 % with the difference of \enquote{\texttt{e}} and $1$.  To avoid
 % confusions, the base of natural logarithms cannot be input as |e| and
-% should be input as \texttt{exp(1)} or \cs{c_e_fp}.
+% should be input as \texttt{exp(1)} or \cs{c_e_fp} (which is faster).
 %
 % Special numbers are input as follows:
 % \begin{itemize}
diff --git a/l3kernel/testfiles/m3fp-parse001.lvt b/l3kernel/testfiles/m3fp-parse001.lvt
index 31b9de850..17b7b660e 100644
--- a/l3kernel/testfiles/m3fp-parse001.lvt
+++ b/l3kernel/testfiles/m3fp-parse001.lvt
@@ -139,4 +139,12 @@
     \fp_to_tl:n { 1 / () pi^(2,) } \NEWLINE
   }
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\int_set:Nn \l_tmpa_int { 3 }
+\TESTEXP { Exponent~e/E }
+  {
+    \fp_to_tl:n { 1E-3 + 3.4e-1 } \NEWLINE
+    \fp_to_tl:n { \l_tmpa_int E \l_tmpa_int + 1 e -\l_tmpa_int }
+  }
+
 \END
diff --git a/l3kernel/testfiles/m3fp-parse001.tlg b/l3kernel/testfiles/m3fp-parse001.tlg
index 38977e3c1..f24d88f6e 100644
--- a/l3kernel/testfiles/m3fp-parse001.tlg
+++ b/l3kernel/testfiles/m3fp-parse001.tlg
@@ -365,3 +365,9 @@ and I'll forget about whatever was undefined.
 0.9999999999999997
 nan
 ============================================================
+============================================================
+TEST 11: Exponent e/E
+============================================================
+0.341
+3000.001
+============================================================





More information about the latex3-commits mailing list.