-
Notifications
You must be signed in to change notification settings - Fork 177
/
l3fp.dtx
1457 lines (1457 loc) · 66.2 KB
/
l3fp.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
%% File: l3fp.dtx Copyright (C) 2011-2019 The LaTeX3 Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version. The latest version
% of this license is in the file
%
% https://www.latex-project.org/lppl.txt
%
% This file is part of the "l3kernel bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
% https://github.com/latex3/latex3
%
% for those people who are interested.
%
%<*driver>
\documentclass[full,kernel]{l3doc}
\usepackage{amsmath}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% ^^A need to provide this inside the file:
%
% \providecommand\nan{\texttt{NaN}}
%
%
% \title{^^A
% The \textsf{l3fp} package: Floating points^^A
% }
%
% \author{^^A
% The \LaTeX3 Project\thanks
% {^^A
% E-mail:
% \href{mailto:latex-team@latex-project.org}
% {latex-team@latex-project.org}^^A
% }^^A
% }
%
% \date{Released 2019-01-01}
%
% \maketitle
%
% \begin{documentation}
%
% A decimal floating point number is one which is stored as a significand and a
% separate exponent. The module implements expandably a wide set of
% arithmetic, trigonometric, and other operations on decimal floating point
% numbers, to be used within floating point expressions. Floating point
% expressions support the following operations with their usual
% precedence.
% \begin{itemize}
% \item Basic arithmetic: addition $x+y$, subtraction $x-y$,
% multiplication $x*y$, division $x/y$, square root~$\sqrt{x}$,
% and parentheses.
% \item Comparison operators: $x\mathop{\mathtt{<}}y$,
% $x\mathop{\mathtt{<=}}y$, $x\mathop{\mathtt{>?}}y$,
% $x\mathop{\mathtt{!=}}y$ \emph{etc.}
% \item Boolean logic: sign $\operatorname{sign} x$,
% negation $\mathop{!}x$, conjunction
% $x\mathop{\&\&}y$, disjunction $x\mathop{\vert\vert}y$, ternary
% operator $x\mathop{?}y\mathop{:}z$.
% \item Exponentials: $\exp x$, $\ln x$, $x^y$.
% \item Trigonometry: $\sin x$, $\cos x$, $\tan x$, $\cot x$, $\sec
% x$, $\csc x$ expecting their arguments in radians, and
% $\operatorname{sind} x$, $\operatorname{cosd} x$,
% $\operatorname{tand} x$, $\operatorname{cotd} x$,
% $\operatorname{secd} x$, $\operatorname{cscd} x$ expecting their
% arguments in degrees.
% \item Inverse trigonometric functions: $\operatorname{asin} x$,
% $\operatorname{acos} x$, $\operatorname{atan} x$,
% $\operatorname{acot} x$, $\operatorname{asec} x$,
% $\operatorname{acsc} x$ giving a result in radians, and
% $\operatorname{asind} x$, $\operatorname{acosd} x$,
% $\operatorname{atand} x$, $\operatorname{acotd} x$,
% $\operatorname{asecd} x$, $\operatorname{acscd} x$ giving a result
% in degrees.
% \item [\emph{(not yet)}] Hyperbolic functions and their inverse
% functions: $\sinh x$, $\cosh x$, $\tanh x$, $\coth x$,
% $\operatorname{sech} x$, $\operatorname{csch}$, and
% $\operatorname{asinh} x$, $\operatorname{acosh} x$,
% $\operatorname{atanh} x$, $\operatorname{acoth} x$,
% $\operatorname{asech} x$, $\operatorname{acsch} x$.
% \item Extrema: $\max(x_{1},x_{2},\ldots)$, $\min(x_{1},x_{2},\ldots)$,
% $\operatorname{abs}(x)$.
% \item Rounding functions ($n=0$ by default, $t=\nan$ by default):
% $\operatorname{trunc}(x,n)$ rounds towards zero,
% $\operatorname{floor}(x,n)$ rounds towards~$-\infty$,
% $\operatorname{ceil}(x,n)$ rounds towards~$+\infty$,
% $\operatorname{round}(x,n,t)$ rounds to the closest value, with
% ties rounded to an even value by default, towards zero if $t=0$,
% towards $+\infty$ if $t>0$ and towards $-\infty$ if $t<0$. And
% \emph{(not yet)} modulo, and \enquote{quantize}.
% \item Random numbers: $\mathop{rand}()$, $\mathop{randint}(m,n)$ in
% all engines except \XeTeX{}.
% \item Constants: \texttt{pi}, \texttt{deg} (one degree in radians).
% \item Dimensions, automatically expressed in points, \emph{e.g.},
% \texttt{pc} is~$12$.
% \item Automatic conversion (no need for \cs[no-index]{\meta{type}_use:N}) of
% integer, dimension, and skip variables to floating point numbers,
% expressing dimensions in points and ignoring the stretch and
% shrink components of skips.
% \item Tuples: $(x_1,\ldots{},x_n)$ that can be stored in variables,
% added together, multiplied or divided by a floating point number,
% and nested.
% \end{itemize}
% Floating point numbers can be given either explicitly (in a form such
% as |1.234e-34|, or |-.0001|), or as a stored floating point variable,
% which is automatically replaced by its current value.
% A \enquote{floating point} is a floating point number or a tuple thereof. See
% section~\ref{sec:l3fp:fp-floats} for a description of what a floating point is,
% section~\ref{sec:l3fp:fp-precedence} for details about how an expression is
% parsed, and section~\ref{sec:l3fp:fp-operations} to know what the various
% operations do. Some operations may raise exceptions (error messages),
% described in section~\ref{sec:l3fp:fp-exceptions}.
%
% An example of use could be the following.
% \begin{verbatim}
% \LaTeX{} can now compute: $ \frac{\sin (3.5)}{2} + 2\cdot 10^{-3}
% = \ExplSyntaxOn \fp_to_decimal:n {sin(3.5)/2 + 2e-3} $.
% \end{verbatim}
% The operation \texttt{round} can be used to limit the result's
% precision. Adding $+0$ avoids the possibly undesirable output |-0|,
% replacing it by |+0|. However, the \pkg{l3fp} module is mostly meant
% as an underlying tool for higher-level commands. For example, one
% could provide a function to typeset nicely the result of floating
% point computations.
% \begin{verbatim}
% \documentclass{article}
% \usepackage{xparse, siunitx}
% \ExplSyntaxOn
% \NewDocumentCommand { \calcnum } { m }
% { \num { \fp_to_scientific:n {#1} } }
% \ExplSyntaxOff
% \begin{document}
% \calcnum { 2 pi * sin ( 2.3 ^ 5 ) }
% \end{document}
% \end{verbatim}
% See the documentation of \pkg{siunitx} for various options of
% \cs{num}.
%
% \section{Creating and initialising floating point variables}
%
% \begin{function}[updated = 2012-05-08, tested = m3fp001]
% {\fp_new:N, \fp_new:c}
% \begin{syntax}
% \cs{fp_new:N} \meta{fp~var}
% \end{syntax}
% Creates a new \meta{fp~var} or raises an error if the name is
% already taken. The declaration is global. The \meta{fp~var} is
% initially~$+0$.
% \end{function}
%
% \begin{function}[updated = 2012-05-08, tested = m3fp001]
% {\fp_const:Nn, \fp_const:cn}
% \begin{syntax}
% \cs{fp_const:Nn} \meta{fp~var} \Arg{floating point expression}
% \end{syntax}
% Creates a new constant \meta{fp~var} or raises an error if the name
% is already taken. The \meta{fp~var} is set globally equal to
% the result of evaluating the \meta{floating point expression}.
% \end{function}
%
% \begin{function}[updated = 2012-05-08, tested = m3fp001]
% {\fp_zero:N, \fp_zero:c, \fp_gzero:N, \fp_gzero:c}
% \begin{syntax}
% \cs{fp_zero:N} \meta{fp~var}
% \end{syntax}
% Sets the \meta{fp~var} to~$+0$.
% \end{function}
%
% \begin{function}[updated = 2012-05-08, tested = m3fp001]
% {\fp_zero_new:N, \fp_zero_new:c, \fp_gzero_new:N, \fp_gzero_new:c}
% \begin{syntax}
% \cs{fp_zero_new:N} \meta{fp~var}
% \end{syntax}
% Ensures that the \meta{fp~var} exists globally
% by applying \cs{fp_new:N} if necessary, then applies
% \cs[index=fp_zero:N]{fp_(g)zero:N} to leave the \meta{fp~var} set to~$+0$.
% \end{function}
%
% \section{Setting floating point variables}
%
% \begin{function}[updated = 2012-05-08, tested = m3fp002]
% {\fp_set:Nn, \fp_set:cn, \fp_gset:Nn, \fp_gset:cn}
% \begin{syntax}
% \cs{fp_set:Nn} \meta{fp~var} \Arg{floating point expression}
% \end{syntax}
% Sets \meta{fp~var} equal to the result of computing the
% \meta{floating point expression}.
% \end{function}
%
% \begin{function}[updated = 2012-05-08, tested = m3fp002]
% {
% \fp_set_eq:NN , \fp_set_eq:cN , \fp_set_eq:Nc , \fp_set_eq:cc ,
% \fp_gset_eq:NN, \fp_gset_eq:cN, \fp_gset_eq:Nc, \fp_gset_eq:cc
% }
% \begin{syntax}
% \cs{fp_set_eq:NN} \meta{fp~var_1} \meta{fp~var_2}
% \end{syntax}
% Sets the floating point variable \meta{fp~var_1} equal to the current
% value of \meta{fp~var_2}.
% \end{function}
%
% \begin{function}[updated = 2012-05-08, tested = m3fp002]
% {\fp_add:Nn, \fp_add:cn, \fp_gadd:Nn, \fp_gadd:cn}
% \begin{syntax}
% \cs{fp_add:Nn} \meta{fp~var} \Arg{floating point expression}
% \end{syntax}
% Adds the result of computing the \meta{floating point expression} to
% the \meta{fp~var}.
% This also applies if \meta{fp~var} and \meta{floating point
% expression} evaluate to tuples of the same size.
% \end{function}
%
% \begin{function}[updated = 2012-05-08, tested = m3fp002]
% {\fp_sub:Nn, \fp_sub:cn, \fp_gsub:Nn, \fp_gsub:cn}
% \begin{syntax}
% \cs{fp_sub:Nn} \meta{fp~var} \Arg{floating point expression}
% \end{syntax}
% Subtracts the result of computing the \meta{floating point
% expression} from the \meta{fp~var}.
% This also applies if \meta{fp~var} and \meta{floating point
% expression} evaluate to tuples of the same size.
% \end{function}
%
% \section{Using floating points}
%
% \begin{function}[EXP, added = 2012-05-08, updated = 2012-07-08,
% tested = m3fp-convert003]{\fp_eval:n}
% \begin{syntax}
% \cs{fp_eval:n} \Arg{floating point expression}
% \end{syntax}
% Evaluates the \meta{floating point expression} and expresses the
% result as a decimal number with no
% exponent. Leading or trailing zeros may be inserted to compensate
% for the exponent. Non-significant trailing zeros are trimmed, and
% integers are expressed without a decimal separator. The values
% $\pm\infty$ and \nan{} trigger an \enquote{invalid operation}
% exception.
% For a tuple, each item is converted using \cs{fp_eval:n} and they are combined as
% |(|\meta{fp_1}\verb*|, |\meta{fp_2}\verb*|, |\ldots{}\meta{fp_n}|)|
% if $n>1$ and |(|\meta{fp_1}|,)| or |()| for fewer items.
% This function is identical to \cs{fp_to_decimal:n}.
% \end{function}
%
% \begin{function}[EXP, added = 2012-05-08, updated = 2012-07-08]
% {\fp_to_decimal:N, \fp_to_decimal:c, \fp_to_decimal:n}
% \begin{syntax}
% \cs{fp_to_decimal:N} \meta{fp~var}
% \cs{fp_to_decimal:n} \Arg{floating point expression}
% \end{syntax}
% Evaluates the \meta{floating point expression} and expresses the
% result as a decimal number with no
% exponent. Leading or trailing zeros may be inserted to compensate
% for the exponent. Non-significant trailing zeros are trimmed, and
% integers are expressed without a decimal separator. The values
% $\pm\infty$ and~\nan{} trigger an \enquote{invalid operation}
% exception.
% For a tuple, each item is converted using \cs{fp_to_decimal:n} and they are combined as
% |(|\meta{fp_1}\verb*|, |\meta{fp_2}\verb*|, |\ldots{}\meta{fp_n}|)|
% if $n>1$ and |(|\meta{fp_1}|,)| or |()| for fewer items.
% \end{function}
%
% \begin{function}[EXP, updated = 2016-03-22]
% {\fp_to_dim:N, \fp_to_dim:c, \fp_to_dim:n}
% \begin{syntax}
% \cs{fp_to_dim:N} \meta{fp~var}
% \cs{fp_to_dim:n} \Arg{floating point expression}
% \end{syntax}
% Evaluates the \meta{floating point expression} and expresses the
% result as a dimension (in~\texttt{pt}) suitable for use in dimension
% expressions. The output is identical to \cs{fp_to_decimal:n}, with
% an additional trailing~\texttt{pt} (both letter tokens).
% In particular, the result may
% be outside the range $[- 2^{14} + 2^{-17}, 2^{14} - 2^{-17}]$ of
% valid \TeX{} dimensions, leading to overflow errors if used as a
% dimension. Tuples, as well as the values $\pm\infty$ and~\nan{},
% trigger an \enquote{invalid operation} exception.
% \end{function}
%
% \begin{function}[EXP, updated = 2012-07-08]
% {\fp_to_int:N, \fp_to_int:c, \fp_to_int:n}
% \begin{syntax}
% \cs{fp_to_int:N} \meta{fp~var}
% \cs{fp_to_int:n} \Arg{floating point expression}
% \end{syntax}
% Evaluates the \meta{floating point expression}, and rounds the
% result to the closest integer, rounding exact ties to an even
% integer.
% The result may be outside the range $[- 2^{31} + 1, 2^{31} - 1]$ of
% valid \TeX{}~integers, leading to overflow errors if used in an
% integer expression. Tuples, as well as the values $\pm\infty$
% and~\nan{}, trigger an \enquote{invalid operation} exception.
% \end{function}
%
% \begin{function}[EXP, added = 2012-05-08, updated = 2016-03-22]
% {\fp_to_scientific:N, \fp_to_scientific:c, \fp_to_scientific:n}
% \begin{syntax}
% \cs{fp_to_scientific:N} \meta{fp~var}
% \cs{fp_to_scientific:n} \Arg{floating point expression}
% \end{syntax}
% Evaluates the \meta{floating point expression} and expresses the
% result in scientific notation:
% \begin{quote}
% \meta{optional \texttt{-}}\meta{digit}\texttt{.}\meta{15 digits}\texttt{e}\meta{optional sign}\meta{exponent}
% \end{quote}
% The leading \meta{digit} is non-zero except in the case of $\pm 0$.
% The values $\pm\infty$ and~\nan{} trigger an \enquote{invalid
% operation} exception. Normal category codes apply: thus the |e| is
% category code~$11$ (a letter).
% For a tuple, each item is converted using \cs{fp_to_scientific:n} and they are combined as
% |(|\meta{fp_1}\verb*|, |\meta{fp_2}\verb*|, |\ldots{}\meta{fp_n}|)|
% if $n>1$ and |(|\meta{fp_1}|,)| or |()| for fewer items.
% \end{function}
%
% \begin{function}[EXP, updated = 2016-03-22]
% {\fp_to_tl:N, \fp_to_tl:c, \fp_to_tl:n}
% \begin{syntax}
% \cs{fp_to_tl:N} \meta{fp~var}
% \cs{fp_to_tl:n} \Arg{floating point expression}
% \end{syntax}
% Evaluates the \meta{floating point expression} and expresses the
% result in (almost) the shortest possible form. Numbers in the
% ranges $(0,10^{-3})$ and $[10^{16},\infty)$ are expressed in
% scientific notation with trailing zeros trimmed and no decimal
% separator when there is a single significant digit (this differs from
% \cs{fp_to_scientific:n}). Numbers in the range $[10^{-3},10^{16})$
% are expressed in a decimal notation without exponent, with trailing
% zeros trimmed, and no decimal separator for integer values (see
% \cs{fp_to_decimal:n}. Negative numbers start with~|-|. The
% special values $\pm 0$, $\pm\infty$ and~\nan{} are rendered as
% |0|, |-0|, \texttt{inf}, \texttt{-inf}, and~\texttt{nan}
% respectively. Normal category codes apply and thus \texttt{inf} or
% \texttt{nan}, if produced, are made up of letters.
% For a tuple, each item is converted using \cs{fp_to_tl:n} and they are combined as
% |(|\meta{fp_1}\verb*|, |\meta{fp_2}\verb*|, |\ldots{}\meta{fp_n}|)|
% if $n>1$ and |(|\meta{fp_1}|,)| or |()| for fewer items.
% \end{function}
%
% \begin{function}[EXP, updated = 2012-07-08]
% {\fp_use:N, \fp_use:c}
% \begin{syntax}
% \cs{fp_use:N} \meta{fp~var}
% \end{syntax}
% Inserts the value of the \meta{fp~var} into the input stream as a
% decimal number with no exponent.
% Leading or trailing zeros may be inserted to compensate for the
% exponent. Non-significant trailing zeros are trimmed. Integers are
% expressed without a decimal separator. The values $\pm\infty$
% and~\nan{} trigger an \enquote{invalid operation} exception.
% For a tuple, each item is converted using \cs{fp_to_decimal:n} and they are combined as
% |(|\meta{fp_1}\verb*|, |\meta{fp_2}\verb*|, |\ldots{}\meta{fp_n}|)|
% if $n>1$ and |(|\meta{fp_1}|,)| or |()| for fewer items.
% This function is identical to \cs{fp_to_decimal:N}.
% \end{function}
%
% \section{Floating point conditionals}
%
% \begin{function}[EXP, pTF, updated = 2012-05-08, tested = m3fp002]
% {\fp_if_exist:N, \fp_if_exist:c}
% \begin{syntax}
% \cs{fp_if_exist_p:N} \meta{fp~var}
% \cs{fp_if_exist:NTF} \meta{fp~var} \Arg{true code} \Arg{false code}
% \end{syntax}
% Tests whether the \meta{fp~var} is currently defined. This does not
% check that the \meta{fp~var} really is a floating point variable.
% \end{function}
%
% \begin{function}[EXP, pTF, updated = 2012-05-08,
% tested = m3fp-logic001]{\fp_compare:nNn}
% \begin{syntax}
% \cs{fp_compare_p:nNn} \Arg{fpexpr_1} \meta{relation} \Arg{fpexpr_2}
% \cs{fp_compare:nNnTF} \Arg{fpexpr_1} \meta{relation} \Arg{fpexpr_2} \Arg{true code} \Arg{false code}
% \end{syntax}
% Compares the \meta{fpexpr_1} and the \meta{fpexpr_2}, and returns
% \texttt{true} if the \meta{relation} is obeyed. Two floating points
% $x$ and~$y$ may obey four mutually exclusive relations:
% $x<y$, $x=y$, $x>y$, or $x?y$ (\enquote{not ordered}). The last
% case occurs exactly if one or both operands is~\nan{} or is a tuple,
% unless they are equal tuples. Note that a~\nan{} is distinct from
% any value, even another~\nan{}, hence $x=x$ is not true for
% a~\nan{}. To test if a value is~\nan{}, compare it to an arbitrary
% number with the \enquote{not ordered} relation.
% \begin{verbatim}
% \fp_compare:nNnTF { <value> } ? { 0 }
% { } % <value> is nan
% { } % <value> is not nan
% \end{verbatim}
% Tuples are equal if they have the same number of items and items
% compare equal (in particular there must be no~\nan{}).
% At present any other comparison with tuples yields |?| (not ordered).
% This is experimental.
% \end{function}
%
% \begin{function}[EXP, pTF, updated = 2013-12-14,
% tested = m3fp-logic001]{\fp_compare:n}
% \begin{syntax}
% \cs{fp_compare_p:n} \\
% ~~\{ \\
% ~~~~\meta{fpexpr_1} \meta{relation_1} \\
% ~~~~\ldots{} \\
% ~~~~\meta{fpexpr_N} \meta{relation_N} \\
% ~~~~\meta{fpexpr_{N+1}} \\
% ~~\} \\
% \cs{fp_compare:nTF}
% ~~\{ \\
% ~~~~\meta{fpexpr_1} \meta{relation_1} \\
% ~~~~\ldots{} \\
% ~~~~\meta{fpexpr_N} \meta{relation_N} \\
% ~~~~\meta{fpexpr_{N+1}} \\
% ~~\} \\
% ~~\Arg{true code} \Arg{false code}
% \end{syntax}
% Evaluates the \meta{floating point expressions} as described for
% \cs{fp_eval:n} and compares consecutive result using the
% corresponding \meta{relation}, namely it compares \meta{intexpr_1}
% and \meta{intexpr_2} using the \meta{relation_1}, then
% \meta{intexpr_2} and \meta{intexpr_3} using the \meta{relation_2},
% until finally comparing \meta{intexpr_N} and \meta{intexpr_{N+1}}
% using the \meta{relation_N}. The test yields \texttt{true} if all
% comparisons are \texttt{true}. Each \meta{floating point
% expression} is evaluated only once. Contrarily to
% \cs{int_compare:nTF}, all \meta{floating point expressions} are
% computed, even if one comparison is \texttt{false}. Two floating
% points $x$ and~$y$ may obey four mutually exclusive
% relations: $x<y$, $x=y$, $x>y$, or $x?y$ (\enquote{not ordered}).
% The last case occurs exactly if one or both operands is~\nan{} or is
% a tuple, unless they are equal tuples. Each \meta{relation}
% can be any (non-empty) combination of |<|, |=|, |>|, and~|?|, plus
% an optional leading~|!| (which negates the \meta{relation}), with
% the restriction that the \meta{relation} may not start with~|?|, as
% this symbol has a different meaning (in combination with~|:|) within
% floating point expressions. The comparison $x$~\meta{relation}~$y$
% is then \texttt{true} if the \meta{relation} does not start with~|!|
% and the actual relation (|<|, |=|, |>|, or~|?|) between $x$ and~$y$
% appears within the \meta{relation}, or on the contrary if the
% \meta{relation} starts with~|!| and the relation between $x$ and~$y$
% does not appear within the \meta{relation}. Common choices of
% \meta{relation} include |>=|~(greater or equal), |!=|~(not equal),
% |!?|~or~|<=>| (comparable).
% \end{function}
%
% \section{Floating point expression loops}
%
% \begin{function}[rEXP, added = 2012-08-16, tested = m3fp-logic003]
% {\fp_do_until:nNnn}
% \begin{syntax}
% \cs{fp_do_until:nNnn} \Arg{fpexpr_1} \meta{relation} \Arg{fpexpr_2} \Arg{code}
% \end{syntax}
% Places the \meta{code} in the input stream for \TeX{} to process,
% and then evaluates the relationship between the two \meta{floating
% point expressions} as described for \cs{fp_compare:nNnTF}. If the
% test is \texttt{false} then the \meta{code} is inserted into
% the input stream again and a loop occurs until the
% \meta{relation} is \texttt{true}.
% \end{function}
%
% \begin{function}[rEXP, added = 2012-08-16, tested = m3fp-logic003]
% {\fp_do_while:nNnn}
% \begin{syntax}
% \cs{fp_do_while:nNnn} \Arg{fpexpr_1} \meta{relation} \Arg{fpexpr_2} \Arg{code}
% \end{syntax}
% Places the \meta{code} in the input stream for \TeX{} to process,
% and then evaluates the relationship between the two \meta{floating
% point expressions} as described for \cs{fp_compare:nNnTF}. If the
% test is \texttt{true} then the \meta{code} is inserted into the
% input stream again and a loop occurs until the \meta{relation}
% is \texttt{false}.
% \end{function}
%
% \begin{function}[rEXP, added = 2012-08-16, tested = m3fp-logic003]
% {\fp_until_do:nNnn}
% \begin{syntax}
% \cs{fp_until_do:nNnn} \Arg{fpexpr_1} \meta{relation} \Arg{fpexpr_2} \Arg{code}
% \end{syntax}
% Evaluates the relationship between the two \meta{floating point
% expressions} as described for \cs{fp_compare:nNnTF}, and then
% places the \meta{code} in the input stream if the \meta{relation} is
% \texttt{false}. After the \meta{code} has been processed by \TeX{}
% the test is repeated, and a loop occurs until the test is
% \texttt{true}.
% \end{function}
%
% \begin{function}[rEXP, added = 2012-08-16, tested = m3fp-logic003]
% {\fp_while_do:nNnn}
% \begin{syntax}
% \cs{fp_while_do:nNnn} \Arg{fpexpr_1} \meta{relation} \Arg{fpexpr_2} \Arg{code}
% \end{syntax}
% Evaluates the relationship between the two \meta{floating point
% expressions} as described for \cs{fp_compare:nNnTF}, and then
% places the \meta{code} in the input stream if the \meta{relation} is
% \texttt{true}. After the \meta{code} has been processed by \TeX{}
% the test is repeated, and a loop occurs until the test is
% \texttt{false}.
% \end{function}
%
% \begin{function}[rEXP, added = 2012-08-16, updated = 2013-12-14, tested = m3fp-logic003]
% {\fp_do_until:nn}
% \begin{syntax}
% \cs{fp_do_until:nn} \{ \meta{fpexpr_1} \meta{relation} \meta{fpexpr_2} \} \Arg{code}
% \end{syntax}
% Places the \meta{code} in the input stream for \TeX{} to process,
% and then evaluates the relationship between the two \meta{floating
% point expressions} as described for \cs{fp_compare:nTF}. If the
% test is \texttt{false} then the \meta{code} is inserted into
% the input stream again and a loop occurs until the
% \meta{relation} is \texttt{true}.
% \end{function}
%
% \begin{function}[rEXP, added = 2012-08-16, updated = 2013-12-14, tested = m3fp-logic003]
% {\fp_do_while:nn}
% \begin{syntax}
% \cs{fp_do_while:nn} \{ \meta{fpexpr_1} \meta{relation} \meta{fpexpr_2} \} \Arg{code}
% \end{syntax}
% Places the \meta{code} in the input stream for \TeX{} to process,
% and then evaluates the relationship between the two \meta{floating
% point expressions} as described for \cs{fp_compare:nTF}. If the
% test is \texttt{true} then the \meta{code} is inserted into the
% input stream again and a loop occurs until the \meta{relation}
% is \texttt{false}.
% \end{function}
%
% \begin{function}[rEXP, added = 2012-08-16, updated = 2013-12-14, tested = m3fp-logic003]
% {\fp_until_do:nn}
% \begin{syntax}
% \cs{fp_until_do:nn} \{ \meta{fpexpr_1} \meta{relation} \meta{fpexpr_2} \} \Arg{code}
% \end{syntax}
% Evaluates the relationship between the two \meta{floating point
% expressions} as described for \cs{fp_compare:nTF}, and then places
% the \meta{code} in the input stream if the \meta{relation} is
% \texttt{false}. After the \meta{code} has been processed by \TeX{}
% the test is repeated, and a loop occurs until the test is
% \texttt{true}.
% \end{function}
%
% \begin{function}[rEXP, added = 2012-08-16, updated = 2013-12-14, tested = m3fp-logic003]
% {\fp_while_do:nn}
% \begin{syntax}
% \cs{fp_while_do:nn} \{ \meta{fpexpr_1} \meta{relation} \meta{fpexpr_2} \} \Arg{code}
% \end{syntax}
% Evaluates the relationship between the two \meta{floating point
% expressions} as described for \cs{fp_compare:nTF}, and then places
% the \meta{code} in the input stream if the \meta{relation} is
% \texttt{true}. After the \meta{code} has been processed by \TeX{}
% the test is repeated, and a loop occurs until the test is
% \texttt{false}.
% \end{function}
%
% \begin{function}[added = 2016-11-21, updated = 2016-12-06, rEXP]
% {\fp_step_function:nnnN, \fp_step_function:nnnc}
% \begin{syntax}
% \cs{fp_step_function:nnnN} \Arg{initial value} \Arg{step} \Arg{final value} \meta{function}
% \end{syntax}
% This function first evaluates the \meta{initial value}, \meta{step}
% and \meta{final value}, each of which should be a floating point
% expression evaluating to a floating point number, not a tuple.
% The \meta{function} is then placed in front of each \meta{value}
% from the \meta{initial value} to the \meta{final value} in turn
% (using \meta{step} between each \meta{value}). The \meta{step} must
% be non-zero. If the \meta{step} is positive, the loop stops when
% the \meta{value} becomes larger than the \meta{final value}. If the
% \meta{step} is negative, the loop stops when the \meta{value}
% becomes smaller than the \meta{final value}. The \meta{function}
% should absorb one numerical argument. For example
% \begin{verbatim}
% \cs_set:Npn \my_func:n #1 { [I~saw~#1] \quad }
% \fp_step_function:nnnN { 1.0 } { 0.1 } { 1.5 } \my_func:n
% \end{verbatim}
% would print
% \begin{quote}
% [I saw 1.0] \quad
% [I saw 1.1] \quad
% [I saw 1.2] \quad
% [I saw 1.3] \quad
% [I saw 1.4] \quad
% [I saw 1.5] \quad
% \end{quote}
% \begin{texnote}
% Due to rounding, it may happen that adding the \meta{step} to the
% \meta{value} does not change the \meta{value}; such cases give an
% error, as they would otherwise lead to an infinite loop.
% \end{texnote}
% \end{function}
%
% \begin{function}[added = 2016-11-21, updated = 2016-12-06]
% {\fp_step_inline:nnnn}
% \begin{syntax}
% \cs{fp_step_inline:nnnn} \Arg{initial value} \Arg{step} \Arg{final value} \Arg{code}
% \end{syntax}
% This function first evaluates the \meta{initial value}, \meta{step}
% and \meta{final value}, all of which should be floating point
% expressions evaluating to a floating point number, not a tuple.
% Then for each \meta{value} from the \meta{initial value} to the
% \meta{final value} in turn (using \meta{step} between each
% \meta{value}), the \meta{code} is inserted into the input stream
% with |#1| replaced by the current \meta{value}. Thus the
% \meta{code} should define a function of one argument~(|#1|).
% \end{function}
%
% \begin{function}[added = 2017-04-12]{\fp_step_variable:nnnNn}
% \begin{syntax}
% \cs{fp_step_variable:nnnNn} \\
% ~~\Arg{initial value} \Arg{step} \Arg{final value} \meta{tl~var} \Arg{code}
% \end{syntax}
% This function first evaluates the \meta{initial value}, \meta{step}
% and \meta{final value}, all of which should be floating point
% expressions evaluating to a floating point number, not a tuple.
% Then for each \meta{value} from the \meta{initial value} to the
% \meta{final value} in turn (using \meta{step} between each
% \meta{value}), the \meta{code} is inserted into the input stream,
% with the \meta{tl~var} defined as the current \meta{value}. Thus
% the \meta{code} should make use of the \meta{tl~var}.
% \end{function}
%
% \section{Some useful constants, and scratch variables}
%
% \begin{variable}[added = 2012-05-08]{\c_zero_fp, \c_minus_zero_fp}
% Zero, with either sign.
% \end{variable}
%
% \begin{variable}[added = 2012-05-08]{\c_one_fp}
% One as an \texttt{fp}: useful for comparisons in some places.
% \end{variable}
%
% \begin{variable}[added = 2012-05-08]{\c_inf_fp, \c_minus_inf_fp}
% Infinity, with either sign. These can be input directly in a
% floating point expression as \texttt{inf} and \texttt{-inf}.
% \end{variable}
%
% \begin{variable}[updated = 2012-05-08]{\c_e_fp}
% The value of the base of the natural logarithm, $\mathrm{e} = \exp(1)$.
% \end{variable}
%
% \begin{variable}[updated = 2013-11-17]{\c_pi_fp}
% The value of~$\pi$. This can be input directly in a floating point
% expression as~\texttt{pi}.
% \end{variable}
%
% \begin{variable}[added = 2012-05-08, updated = 2013-11-17]
% {\c_one_degree_fp}
% The value of $1^{\circ}$ in radians. Multiply an angle given in
% degrees by this value to obtain a result in radians. Note that
% trigonometric functions expecting an argument in radians or in
% degrees are both available. Within floating point expressions, this
% can be accessed as \texttt{deg}.
% \end{variable}
%
% \begin{variable}{\l_tmpa_fp, \l_tmpb_fp}
% Scratch floating points for local assignment. These are never used by
% the kernel code, and so are safe for use with any \LaTeX3-defined
% function. However, they may be overwritten by other non-kernel
% code and so should only be used for short-term storage.
% \end{variable}
%
% \begin{variable}{\g_tmpa_fp, \g_tmpb_fp}
% Scratch floating points for global assignment. These are never used by
% the kernel code, and so are safe for use with any \LaTeX3-defined
% function. However, they may be overwritten by other non-kernel
% code and so should only be used for short-term storage.
% \end{variable}
%
% \section{Floating point exceptions}
% \label{sec:l3fp:fp-exceptions}
%
% \emph{The functions defined in this section are experimental, and
% their functionality may be altered or removed altogether.}
%
% \enquote{Exceptions} may occur when performing some floating point
% operations, such as \texttt{0 / 0}, or \texttt{10 ** 1e9999}. The
% relevant \textsc{IEEE} standard defines $5$ types of exceptions,
% of which we implement~$4$.
% \begin{itemize}
% \item \emph{Overflow} occurs whenever the result of an operation is
% too large to be represented as a normal floating point number. This
% results in $\pm \infty$.
% \item \emph{Underflow} occurs whenever the result of an operation is
% too close to $0$ to be represented as a normal floating point
% number. This results in $\pm 0$.
% \item \emph{Invalid operation} occurs for operations with no defined
% outcome, for instance $0/0$ or $\sin(\infty)$, and results in a \nan{}.
% It also occurs for conversion functions whose target type does not
% have the appropriate infinite or \nan{} value (\emph{e.g.},
% \cs{fp_to_dim:n}).
% \item \emph{Division by zero} occurs when dividing a non-zero number
% by $0$, or when evaluating functions at poles, \emph{e.g.},
% $\ln(0)$ or $\cot(0)$. This results in $\pm\infty$.
% \item [\emph{(not yet)}] \emph{Inexact} occurs whenever the result of
% a computation is not exact, in other words, almost always. At the
% moment, this exception is entirely ignored in \LaTeX3.
% \end{itemize}
% To each exception we associate a \enquote{flag}: \texttt{fp_overflow},
% \texttt{fp_underflow}, \texttt{fp_invalid_operation} and
% \texttt{fp_division_by_zero}. The state of these flags can be tested
% and modified with commands from \pkg{l3flag}
%
% By default, the \enquote{invalid operation} exception triggers an
% (expandable) error, and raises the corresponding flag. Other
% exceptions raise the corresponding flag but do not trigger an error.
% The behaviour when an exception occurs can be modified (using
% \cs{fp_trap:nn}) to either produce an error and raise the flag, or
% only raise the flag, or do nothing at all.
%
% \begin{function}[added = 2012-07-19, updated = 2017-02-13,
% tested = m3fp-traps001]{\fp_trap:nn}
% \begin{syntax}
% \cs{fp_trap:nn} \Arg{exception} \Arg{trap type}
% \end{syntax}
% All occurrences of the \meta{exception} (\texttt{overflow},
% \texttt{underflow}, \texttt{invalid_operation} or
% \texttt{division_by_zero}) within the current
% group are treated as \meta{trap type}, which can be
% \begin{itemize}
% \item \texttt{none}: the \meta{exception} will be entirely
% ignored, and leave no trace;
% \item \texttt{flag}: the \meta{exception} will turn the
% corresponding flag on when it occurs;
% \item \texttt{error}: additionally, the \meta{exception} will halt
% the \TeX{} run and display some information about the current
% operation in the terminal.
% \end{itemize}
% \emph{This function is experimental, and may be altered or removed.}
% \end{function}
%
% \begin{variable}
% {
% flag fp_overflow,
% flag fp_underflow,
% flag fp_invalid_operation,
% flag fp_division_by_zero
% }
% Flags denoting the occurrence of various floating-point exceptions.
% \end{variable}
%
% \section{Viewing floating points}
%
% \begin{function}[added = 2012-05-08, updated = 2015-08-07,
% tested = m3fp002]{\fp_show:N, \fp_show:c, \fp_show:n}
% \begin{syntax}
% \cs{fp_show:N} \meta{fp~var}
% \cs{fp_show:n} \Arg{floating point expression}
% \end{syntax}
% Evaluates the \meta{floating point expression} and displays the
% result in the terminal.
% \end{function}
%
% \begin{function}[added = 2014-08-22, updated = 2015-08-07]
% {\fp_log:N, \fp_log:c, \fp_log:n}
% \begin{syntax}
% \cs{fp_log:N} \meta{fp~var}
% \cs{fp_log:n} \Arg{floating point expression}
% \end{syntax}
% Evaluates the \meta{floating point expression} and writes the
% result in the log file.
% \end{function}
%
% \section{Floating point expressions}
%
% \subsection{Input of floating point numbers} \label{sec:l3fp:fp-floats}
%
% We support four types of floating point numbers:
% \begin{itemize}
% \item $\pm m \cdot 10^{n}$, a floating
% point number, with integer $1\leq m\leq 10^{16}$, and
% $-{\ExplSyntaxOn\int_use:N\c__fp_minus_min_exponent_int}\leq
% n\leq {\ExplSyntaxOn\int_use:N\c__fp_max_exponent_int}$;
% \item $\pm 0$, zero, with a given sign;
% \item $\pm \infty$, infinity, with a given sign;
% \item \nan{}, is \enquote{not a number}, and can be either quiet
% or signalling (\emph{not yet}: this distinction is currently
% unsupported);
% \end{itemize}
% Normal floating point numbers are stored in base $10$, with up to $16$
% significant figures.
%
% On input, a normal floating point number consists of:
% \begin{itemize}
% \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
% possibly empty string of |+|~and~|-| tokens, and a non-empty string
% of digits.
% \end{itemize}
% The sign of the resulting number is |+| if \meta{sign} contains an
% even number of |-|, and |-| otherwise, hence, an empty \meta{sign}
% denotes a non-negative input. The stored significand is obtained from
% \meta{significand} by omitting the decimal separator and leading zeros,
% and rounding to $16$ significant digits, filling with trailing zeros
% if necessary. In particular, the value stored is exact if the input
% \meta{significand} has at most $16$ digits. The stored \meta{exponent}
% is obtained by combining the input \meta{exponent} ($0$ if absent)
% with a shift depending on the position of the significand and the number
% of leading zeros.
%
% A special case arises if the resulting \meta{exponent} is either too
% large or too small for the floating point number to be
% represented. This results either in an overflow (the number is then
% replaced by $\pm\infty$), or an underflow (resulting in $\pm 0$).
%
% The result is thus $\pm 0$ if and only if \meta{significand} contains no
% non-zero digit (\emph{i.e.}, consists only in characters~|0|, and an
% optional period), or if there is an underflow. Note that a
% single dot is currently a valid floating point number, equal to~$+0$,
% but that is not guaranteed to remain true.
%
% The \meta{significand} must be non-empty, so |e1| and |e-1| are not
% 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}.
%
% Special numbers are input as follows:
% \begin{itemize}
% \item \texttt{inf} represents $+\infty$, and can be preceded by any
% \meta{sign}, yielding $\pm\infty$ as appropriate.
% \item \texttt{nan} represents a (quiet) non-number. It can be
% preceded by any sign, but that sign is ignored.
% \item Any unrecognizable string triggers an error, and produces a
% \nan{}.
% \item Note that commands such as \tn{infty}, \tn{pi}, or \tn{sin}
% \emph{do not} work in floating point expressions. They may
% silently be interpreted as completely unexpected numbers, because
% integer constants (allowed in expressions) are commonly stored as
% mathematical characters.
% \end{itemize}
%
% \subsection{Precedence of operators}
% \label{sec:l3fp:fp-precedence}
%
% We list here all the operations supported in floating point
% expressions, in order of decreasing precedence: operations listed
% earlier bind more tightly than operations listed below them.
% \begin{itemize}
% \item Function calls (\texttt{sin}, \texttt{ln}, \emph{etc}).
% \item Binary |**| and |^| (right associative).
% \item Unary |+|, |-|, |!|.
% \item Binary |*|, |/|, and implicit multiplication by juxtaposition
% (\texttt{2pi}, \texttt{3(4+5)}, \emph{etc}).
% \item Binary |+| and |-|.
% \item Comparisons |>=|, |!=|, |<?|, \emph{etc}.
% \item Logical \texttt{and}, denoted by |&&|.
% \item Logical \texttt{or}, denoted by \verb+||+.
% \item Ternary operator |?:| (right associative).
% \item Comma (to build tuples).
% \end{itemize}
% The precedence of operations can be overridden using parentheses.
% In particular, those precedences imply that
% \begin{align*}
% \mathtt{sin 2pi} & = \sin(2)\pi != 0, \\
% \mathtt{2\char`\^2max(3,5)} & = 2^2 \max(3,5) = 20.
% \end{align*}
% Functions are called on the value of their argument, contrarily to
% \TeX{} macros.
%
% \subsection{Operations} \label{sec:l3fp:fp-operations}
%
% We now present the various operations allowed in floating point
% expressions, from the lowest precedence to the highest. When used as
% a truth value, a floating point expression is \texttt{false} if it is
% $\pm 0$, and \texttt{true} otherwise, including when it is \nan{} or a
% tuple such as $(0,0)$. Tuples are only supported to some extent by
% operations that work with truth values (|?:|, \verb"||", |&&|, |!|),
% by comparisons (|!<=>?|), and by |+|, |-|, |*|, |/|. Unless otherwise
% specified, providing a tuple as an argument of any other operation
% yields the \enquote{invalid operation} exception and a \nan{} result.
%
% \begin{function}[tested = m3fp-logic002, module = ]{?:}
% \begin{syntax}
% \cs{fp_eval:n} \{ \meta{operand_1} |?| \meta{operand_2} |:| \meta{operand_3} \}
% \end{syntax}
% The ternary operator |?:| results in \meta{operand_2} if
% \meta{operand_1} is true (not $\pm 0$), and \meta{operand_3} if \meta{operand_1}
% is false ($\pm 0$). All three \meta{operands} are evaluated in all
% cases; they may be tuples. The operator is right associative, hence
% \begin{verbatim}
% \fp_eval:n
% {
% 1 + 3 > 4 ? 1 :
% 2 + 4 > 5 ? 2 :
% 3 + 5 > 6 ? 3 : 4
% }
% \end{verbatim}
% first tests whether $1 + 3 > 4$; since this isn't true, the branch
% following |:| is taken, and $2 + 4 > 5$ is compared; since this is
% true, the branch before |:| is taken, and everything else is
% (evaluated then) ignored. That allows testing for various cases in
% a concise manner, with the drawback that all computations are made
% in all cases.
% \end{function}
%
% \begin{function}[tested = m3fp-logic002]{||}
% \begin{syntax}
% \cs{fp_eval:n} \{ \meta{operand_1} \verb"||" \meta{operand_2} \}
% \end{syntax}
% If \meta{operand_1} is true (not $\pm 0$), use that value, otherwise the
% value of \meta{operand_2}. Both \meta{operands} are evaluated in all
% cases; they may be tuples. In \meta{operand_1} \verb"||"
% \meta{operand_2} \verb"||" \ldots{} \verb"||" \meta{operands_n}, the
% first true (nonzero) \meta{operand} is used and if all are zero the
% last one ($\pm 0$) is used.
% \end{function}
%
% \begin{function}[tested = m3fp-logic002]{&&}
% \begin{syntax}
% \cs{fp_eval:n} \{ \meta{operand_1} |&&| \meta{operand_2} \}
% \end{syntax}
% If \meta{operand_1} is false (equal to~$\pm 0$), use that value,
% otherwise the value of \meta{operand_2}. Both \meta{operands} are
% evaluated in all cases; they may be tuples. In \meta{operand_1}
% |&&| \meta{operand_2} |&&| \ldots{} |&&| \meta{operands_n}, the
% first false ($\pm 0$) \meta{operand} is used and if none is zero the
% last one is used.
% \end{function}
%
% \begin{function}[tested = m3fp-logic001, updated = 2013-12-14]
% {<, =, >, ?}
% \begin{syntax}
% \cs{fp_eval:n} \\
% ~~\{ \\
% ~~~~\meta{operand_1} \meta{relation_1} \\
% ~~~~\ldots{} \\
% ~~~~\meta{operand_N} \meta{relation_N} \\
% ~~~~\meta{operand_{N+1}} \\
% ~~\}
% \end{syntax}
% Each \meta{relation} consists of a non-empty string of |<|, |=|,
% |>|, and~|?|, optionally preceded by~|!|, and may not start
% with~|?|. This evaluates to $+1$ if all comparisons
% \meta{operand_i} \meta{relation_i} \meta{operand_{i+1}} are true, and
% $+0$ otherwise. All \meta{operands} are evaluated (once) in all cases.
% See \cs{fp_compare:nTF} for details.
% \end{function}
%
% \begin{function}[tested = m3fp-basics001]{+, -}
% \begin{syntax}
% \cs{fp_eval:n} \{ \meta{operand_1} |+| \meta{operand_2} \}
% \cs{fp_eval:n} \{ \meta{operand_1} |-| \meta{operand_2} \}
% \end{syntax}
% Computes the sum or the difference of its two \meta{operands}. The
% \enquote{invalid operation} exception occurs for $\infty-\infty$.
% \enquote{Underflow} and \enquote{overflow} occur when appropriate.
% These operations supports the itemwise addition or subtraction of
% two tuples, but if they have a different number of items the
% \enquote{invalid operation} exception occurs and the result is \nan{}.
% \end{function}
%
% \begin{function}[tested = {m3fp-basics002, m3fp-basics003}]{*, /}
% \begin{syntax}
% \cs{fp_eval:n} \{ \meta{operand_1} |*| \meta{operand_2} \}
% \cs{fp_eval:n} \{ \meta{operand_1} |/| \meta{operand_2} \}
% \end{syntax}
% Computes the product or the ratio of its two \meta{operands}. The
% \enquote{invalid operation} exception occurs for $\infty/\infty$,
% $0/0$, or $0*\infty$. \enquote{Division by zero} occurs when
% dividing a finite non-zero number by $\pm 0$. \enquote{Underflow}
% and \enquote{overflow} occur when appropriate.
% When \meta{operand_1} is a tuple and \meta{operand_2} is a floating
% point number, each item of \meta{operand_1} is multiplied or divided
% by \meta{operand_2}. Multiplication also supports the case where
% \meta{operand_1} is a floating point number and \meta{operand_2} a
% tuple. Other combinations yield an \enquote{invalid operation}
% exception and a \nan{} result.
% \end{function}
%
% \begin{function}[tested = m3fp-basics004, label = !]{+, -, !}
% \begin{syntax}
% \cs{fp_eval:n} \{ |+| \meta{operand} \}
% \cs{fp_eval:n} \{ |-| \meta{operand} \}
% \cs{fp_eval:n} \{ |!| \meta{operand} \}
% \end{syntax}
% The unary |+| does nothing, the unary |-| changes the sign of the
% \meta{operand} (for a tuple, of all its components), and
% |!| \meta{operand} evaluates to $1$ if \meta{operand} is false
% (is $\pm 0$) and $0$ otherwise (this is the \texttt{not}
% boolean function). Those operations never raise exceptions.
% \end{function}
%
% \begin{function}[tested = m3fp-expo001]{**, ^}
% \begin{syntax}
% \cs{fp_eval:n} \{ \meta{operand_1} |**| \meta{operand_2} \}
% \cs{fp_eval:n} \{ \meta{operand_1} |^| \meta{operand_2} \}
% \end{syntax}
% Raises \meta{operand_1} to the power \meta{operand_2}. This
% operation is right associative, hence \texttt{2 ** 2 ** 3} equals
% $2^{2^{3}} = 256$. If \meta{operand_1} is negative or $-0$ then:
% the result's sign is $+$ if the \meta{operand_2} is infinite and
% $(-1)^p$ if the \meta{operand_2} is $p/5^q$ with $p$, $q$ integers;
% the result is $+0$ if
% |abs(|\meta{operand_1}|)^|\meta{operand_2} evaluates to zero; in