[latex3-commits] [git/LaTeX3-latex3-latex3] master: Provide function to test for nan floating point (3ea74ddae)

Bruno Le Floch bruno at le-floch.fr
Sun Aug 25 14:05:50 CEST 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/3ea74ddaee8c2ede16ed45194e6267b77cd12845

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

commit 3ea74ddaee8c2ede16ed45194e6267b77cd12845
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Sun Aug 25 14:03:39 2019 +0200

    Provide function to test for nan floating point


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

3ea74ddaee8c2ede16ed45194e6267b77cd12845
 l3kernel/CHANGELOG.md                   |  4 ++++
 l3kernel/l3candidates.dtx               |  9 +++++++++
 l3kernel/l3fp-logic.dtx                 | 17 ++++++++++++++++-
 l3kernel/l3fp.dtx                       |  2 +-
 l3kernel/testfiles/m3expl001.luatex.tlg |  4 ++++
 l3kernel/testfiles/m3expl001.ptex.tlg   |  4 ++++
 l3kernel/testfiles/m3expl001.tlg        |  4 ++++
 l3kernel/testfiles/m3expl001.uptex.tlg  |  4 ++++
 l3kernel/testfiles/m3expl001.xetex.tlg  |  4 ++++
 l3kernel/testfiles/m3expl003.luatex.tlg |  4 ++++
 l3kernel/testfiles/m3expl003.ptex.tlg   |  4 ++++
 l3kernel/testfiles/m3expl003.tlg        |  4 ++++
 l3kernel/testfiles/m3expl003.uptex.tlg  |  4 ++++
 l3kernel/testfiles/m3expl003.xetex.tlg  |  4 ++++
 14 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 5ddc54b27..d4ab00a61 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,10 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Added
+
+- `\fp_if_nan:nTF`
+
 ### Changed
 
 - Make round(.,nan)=nan with no "Invalid operation" error
diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index 4875295f8..c34627161 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -246,6 +246,15 @@
 %   is~$0$.
 % \end{function}
 %
+% \begin{function}[pTF, added = 2019-08-25]{\fp_if_nan:n}
+%   \begin{syntax}
+%     \cs{fp_if_nan:n} \Arg{fpexpr}
+%   \end{syntax}
+%   Evaluates the \meta{fpexpr} and tests whether the result is exactly
+%   \nan{}.  The test returns \texttt{false} for any other result, even
+%   a tuple containing \nan{}.
+% \end{function}
+%
 % \section{Additions to \pkg{l3fparray}}
 %
 % \begin{function}[added = 2018-05-05]{\fparray_new:Nn}
diff --git a/l3kernel/l3fp-logic.dtx b/l3kernel/l3fp-logic.dtx
index 01aa7777c..1cdadd33e 100644
--- a/l3kernel/l3fp-logic.dtx
+++ b/l3kernel/l3fp-logic.dtx
@@ -83,7 +83,7 @@
 %     \cs{@@_ternary_auxii:NwwN} have to be understood.
 % \end{itemize}
 %
-% \subsection{Existence test}
+% \subsection{Tests}
 %
 % \begin{macro}[pTF]{\fp_if_exist:N, \fp_if_exist:c}
 %   Copies of the \texttt{cs} functions defined in \pkg{l3basics}.
@@ -93,6 +93,21 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}[pTF]{\fp_if_nan:n}
+%   Evaluate and check if the result is a floating point of the same
+%   kind as \nan{}.
+%    \begin{macrocode}
+\prg_new_conditional:Npnn \fp_if_nan:n #1 { TF , T , F , p }
+  {
+    \if:w 3 \exp_last_unbraced:Nf \@@_kind:w { \@@_parse:n {#1} }
+      \prg_return_true:
+    \else:
+      \prg_return_false:
+    \fi:
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{Comparison}
 %
 % \begin{macro}[pTF, EXP]{\fp_compare:n}
diff --git a/l3kernel/l3fp.dtx b/l3kernel/l3fp.dtx
index c8c360b41..176c2b032 100644
--- a/l3kernel/l3fp.dtx
+++ b/l3kernel/l3fp.dtx
@@ -1420,7 +1420,7 @@
 %   \item Add an |array(1,2,3)| and |i=complex(0,1)|.
 %   \item Provide an experimental |map| function?  Perhaps easier to
 %     implement if it is a single character, |@sin(1,2)|?
-%   \item Provide \cs{fp_if_nan:nTF}, and an |isnan| function?
+%   \item Provide an |isnan| function analogue of \cs{fp_if_nan:nTF}?
 %   \item Support keyword arguments?
 % \end{itemize}
 % \pkg{Pgfmath} also provides box-measurements (depth, height, width), but
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 791f928e3..87e545402 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -3954,6 +3954,10 @@ Defining \fp_if_exist:cTF on line ...
 Defining \fp_if_exist:cT on line ...
 Defining \fp_if_exist:cF on line ...
 Defining \fp_if_exist_p:c on line ...
+Defining \fp_if_nan:nTF on line ...
+Defining \fp_if_nan:nT on line ...
+Defining \fp_if_nan:nF on line ...
+Defining \fp_if_nan_p:n on line ...
 Defining \fp_compare_p:n on line ...
 Defining \fp_compare:nT on line ...
 Defining \fp_compare:nF on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index fe937efd9..90e3cd893 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -4208,6 +4208,10 @@ Defining \fp_if_exist:cTF on line ...
 Defining \fp_if_exist:cT on line ...
 Defining \fp_if_exist:cF on line ...
 Defining \fp_if_exist_p:c on line ...
+Defining \fp_if_nan:nTF on line ...
+Defining \fp_if_nan:nT on line ...
+Defining \fp_if_nan:nF on line ...
+Defining \fp_if_nan_p:n on line ...
 Defining \fp_compare_p:n on line ...
 Defining \fp_compare:nT on line ...
 Defining \fp_compare:nF on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 302bd8c2d..76ac6ba9f 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -4208,6 +4208,10 @@ Defining \fp_if_exist:cTF on line ...
 Defining \fp_if_exist:cT on line ...
 Defining \fp_if_exist:cF on line ...
 Defining \fp_if_exist_p:c on line ...
+Defining \fp_if_nan:nTF on line ...
+Defining \fp_if_nan:nT on line ...
+Defining \fp_if_nan:nF on line ...
+Defining \fp_if_nan_p:n on line ...
 Defining \fp_compare_p:n on line ...
 Defining \fp_compare:nT on line ...
 Defining \fp_compare:nF on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 4ec41fd4a..77437160e 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -4208,6 +4208,10 @@ Defining \fp_if_exist:cTF on line ...
 Defining \fp_if_exist:cT on line ...
 Defining \fp_if_exist:cF on line ...
 Defining \fp_if_exist_p:c on line ...
+Defining \fp_if_nan:nTF on line ...
+Defining \fp_if_nan:nT on line ...
+Defining \fp_if_nan:nF on line ...
+Defining \fp_if_nan_p:n on line ...
 Defining \fp_compare_p:n on line ...
 Defining \fp_compare:nT on line ...
 Defining \fp_compare:nF on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 7d58592c9..b9d3f8272 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -3952,6 +3952,10 @@ Defining \fp_if_exist:cTF on line ...
 Defining \fp_if_exist:cT on line ...
 Defining \fp_if_exist:cF on line ...
 Defining \fp_if_exist_p:c on line ...
+Defining \fp_if_nan:nTF on line ...
+Defining \fp_if_nan:nT on line ...
+Defining \fp_if_nan:nF on line ...
+Defining \fp_if_nan_p:n on line ...
 Defining \fp_compare_p:n on line ...
 Defining \fp_compare:nT on line ...
 Defining \fp_compare:nF on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 791f928e3..87e545402 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -3954,6 +3954,10 @@ Defining \fp_if_exist:cTF on line ...
 Defining \fp_if_exist:cT on line ...
 Defining \fp_if_exist:cF on line ...
 Defining \fp_if_exist_p:c on line ...
+Defining \fp_if_nan:nTF on line ...
+Defining \fp_if_nan:nT on line ...
+Defining \fp_if_nan:nF on line ...
+Defining \fp_if_nan_p:n on line ...
 Defining \fp_compare_p:n on line ...
 Defining \fp_compare:nT on line ...
 Defining \fp_compare:nF on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index fe937efd9..90e3cd893 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -4208,6 +4208,10 @@ Defining \fp_if_exist:cTF on line ...
 Defining \fp_if_exist:cT on line ...
 Defining \fp_if_exist:cF on line ...
 Defining \fp_if_exist_p:c on line ...
+Defining \fp_if_nan:nTF on line ...
+Defining \fp_if_nan:nT on line ...
+Defining \fp_if_nan:nF on line ...
+Defining \fp_if_nan_p:n on line ...
 Defining \fp_compare_p:n on line ...
 Defining \fp_compare:nT on line ...
 Defining \fp_compare:nF on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 302bd8c2d..76ac6ba9f 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -4208,6 +4208,10 @@ Defining \fp_if_exist:cTF on line ...
 Defining \fp_if_exist:cT on line ...
 Defining \fp_if_exist:cF on line ...
 Defining \fp_if_exist_p:c on line ...
+Defining \fp_if_nan:nTF on line ...
+Defining \fp_if_nan:nT on line ...
+Defining \fp_if_nan:nF on line ...
+Defining \fp_if_nan_p:n on line ...
 Defining \fp_compare_p:n on line ...
 Defining \fp_compare:nT on line ...
 Defining \fp_compare:nF on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 4ec41fd4a..77437160e 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -4208,6 +4208,10 @@ Defining \fp_if_exist:cTF on line ...
 Defining \fp_if_exist:cT on line ...
 Defining \fp_if_exist:cF on line ...
 Defining \fp_if_exist_p:c on line ...
+Defining \fp_if_nan:nTF on line ...
+Defining \fp_if_nan:nT on line ...
+Defining \fp_if_nan:nF on line ...
+Defining \fp_if_nan_p:n on line ...
 Defining \fp_compare_p:n on line ...
 Defining \fp_compare:nT on line ...
 Defining \fp_compare:nF on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 7d58592c9..b9d3f8272 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -3952,6 +3952,10 @@ Defining \fp_if_exist:cTF on line ...
 Defining \fp_if_exist:cT on line ...
 Defining \fp_if_exist:cF on line ...
 Defining \fp_if_exist_p:c on line ...
+Defining \fp_if_nan:nTF on line ...
+Defining \fp_if_nan:nT on line ...
+Defining \fp_if_nan:nF on line ...
+Defining \fp_if_nan_p:n on line ...
 Defining \fp_compare_p:n on line ...
 Defining \fp_compare:nT on line ...
 Defining \fp_compare:nF on line ...





More information about the latex3-commits mailing list