Debian Codegraph @

texmf-dist/source/latex/l3kernel/l3fp-types.dtx

raw
1 % \iffalse
2 %
3 %% File l3fp-types.dtx (C) Copyright 2012-2015,2017,2018,2020,2021,2023 The LaTeX Project
4 %
5 % It may be distributed and/or modified under the conditions of the
6 % LaTeX Project Public License (LPPL), either version 1.3c of this
7 % license or (at your option) any later version. The latest version
8 % of this license is in the file
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % This file is part of the "l3kernel bundle" (The Work in LPPL)
13 % and all files in that bundle must be distributed together.
14 %
15 % -----------------------------------------------------------------------
16 %
17 % The development version of the bundle can be found at
18 %
19 % https://github.com/latex3/latex3
20 %
21 % for those people who are interested.
22 %
23 %<*driver>
24 \documentclass[full]{l3doc}
25 \usepackage{amsmath}
26 \begin{document}
27 \DocInput{\jobname.dtx}
28 \end{document}
29 %</driver>
30 % \fi
31 %
32 % \title{^^A
33 % The \pkg{l3fp-types} module\\ Floating point types^^A
34 % }
35 %
36 % \author{^^A
37 % The \LaTeX{} Project\thanks
38 % {^^A
39 % E-mail:
40 % \href{mailto:[email protected]}
41 % {[email protected]}^^A
42 % }^^A
43 % }
44 %
45 % \date{Released 2026-05-15}
46 %
47 % \maketitle
48 %
49 % \begin{documentation}
50 %
51 % \end{documentation}
52 %
53 % \begin{implementation}
54 %
55 % \section{\pkg{l3fp-types} implementation}
56 %
57 % \begin{macrocode}
58 %<*code>
59 % \end{macrocode}
60 %
61 % \begin{macrocode}
62 %<@@=fp>
63 % \end{macrocode}
64 %
65 % \subsection{Support for types}
66 %
67 % Despite lack of documentation, the \pkg{l3fp} internals support types.
68 % Each additional type must define
69 % \begin{itemize}
70 % \item |\s__fp_|\meta{type} and |\__fp_|\meta{type}|_chk:w|;
71 % \item |\__fp_exp_after_|\meta{type}|_f:nw|;
72 % \item |\__fp_|\meta{type}|_to_|\meta{out}|:w| for \meta{out} among
73 % |decimal|, |scientific|, |tl|;
74 % \end{itemize}
75 % and may define
76 % \begin{itemize}
77 % \item |\__fp_|\meta{type}|_to_int:w| and |\__fp_|\meta{type}|_to_dim:w|;
78 % \item |\__fp_|\meta{op}|_|\meta{type}|_o:w| for any of the \meta{op}
79 % that the type implements, among |acos|, |acsc|, |asec|, |asin|,
80 % |cos|, |cot|, |csc|, |exp|, |ln|, |not|, |sec|, |set_sign|, |sin|,
81 % |tan|;
82 % \item |\__fp_|\meta{type_1}|_|\meta{op}|_|\meta{type_2}|_o:ww| for
83 % \meta{op} among |^*/-+&|\verb"|" and for every pair of types;
84 % \item |\__fp_|\meta{type_1}|_bcmp_|\meta{type_2}|:ww| for every
85 % pair of types.
86 % \end{itemize}
87 % The latter is set up in \pkg{l3fp-logic}.
88 %
89 % \subsection{Dispatch according to the type}
90 %
91 % \begin{macro}[EXP]
92 % {\@@_types_cs_to_op:N, \@@_types_cs_to_op_auxi:wwwn}
93 % From |\__fp_|\meta{op}|_o:w| produce \meta{op}, otherwise~|?|.
94 % \begin{macrocode}
95 \cs_new:Npe \@@_types_cs_to_op:N #1
96 {
97 \exp_not:N \exp_after:wN \exp_not:N \@@_types_cs_to_op_auxi:wwwn
98 \exp_not:N \token_to_str:N #1 \s_@@_mark
99 \exp_not:N \@@_use_i_delimit_by_s_stop:nw
100 \tl_to_str:n { @@_ _o:w } \s_@@_mark
101 { \exp_not:N \@@_use_i_delimit_by_s_stop:nw ? }
102 \s_@@_stop
103 }
104 \use:e
105 {
106 \cs_new:Npn \exp_not:N \@@_types_cs_to_op_auxi:wwwn
107 #1 \tl_to_str:n { @@_ } #2
108 \tl_to_str:n { _o:w } #3 \s_@@_mark #4 { #4 {#2} }
109 }
110 % \end{macrocode}
111 % \end{macro}
112 %
113 % \begin{macro}[EXP]{\@@_types_unary:NNw}
114 % \begin{macro}[EXP]
115 % {\@@_types_unary_auxi:nNw, \@@_types_unary_auxii:NnNw}
116 % \begin{syntax}
117 % \cs{@@_types_unary:NNw} |\__fp_|\meta{function}|_o:w|
118 % ~~\meta{token} \meta{operand} |@|
119 % \end{syntax}
120 % \begin{macrocode}
121 \cs_new:Npn \@@_types_unary:NNw #1
122 {
123 \exp_args:Nf \@@_types_unary_auxi:nNw
124 { \@@_types_cs_to_op:N #1 }
125 }
126 \cs_new:Npn \@@_types_unary_auxi:nNw #1#2#3
127 {
128 \exp_after:wN \@@_types_unary_auxii:NnNw
129 \cs:w @@_#1 \@@_type_from_scan:N #3 _o:w \cs_end:
130 {#1}
131 #2#3
132 }
133 \cs_new:Npn \@@_types_unary_auxii:NnNw #1#2#3
134 {
135 \token_if_eq_meaning:NNTF \scan_stop: #1
136 { \@@_invalid_operation_o:nw {#2} }
137 { #1 #3 }
138 }
139 % \end{macrocode}
140 % \end{macro}
141 % \end{macro}
142 %
143 % \begin{macro}[EXP]{\@@_types_binary:Nww}
144 % \begin{macro}[EXP]
145 % {\@@_types_binary_auxi:Nww, \@@_types_binary_auxii:NNww}
146 % \begin{syntax}
147 % \cs{@@_types_binary:Nww} |\__fp_|\meta{binop}|_o:ww|
148 % ~~\meta{operand_1} \meta{operand_2} |@|
149 % \end{syntax}
150 % \begin{macrocode}
151 \cs_new:Npn \@@_types_binary:Nww #1
152 {
153 \exp_last_unbraced:Nf \@@_types_binary_auxi:Nww
154 { \@@_types_cs_to_op:N #1 }
155 }
156 \cs_new:Npn \@@_types_binary_auxi:Nww #1#2#3\@@_sep: #4#5\@@_sep: @
157 {
158 \exp_after:wN \@@_types_binary_auxii:NNww
159 \cs:w
160 @@
161 \@@_type_from_scan:N #2
162 _#1
163 \@@_type_from_scan:N #4
164 _o:ww
165 \cs_end:
166 #1 #2#3\@@_sep: #4#5\@@_sep:
167 }
168 \cs_new:Npn \@@_types_binary_auxii:NNww #1#2
169 {
170 \token_if_eq_meaning:NNTF \scan_stop: #1
171 { \@@_invalid_operation_o:Nww #2 }
172 {#1}
173 }
174 % \end{macrocode}
175 % \end{macro}
176 % \end{macro}
177 %
178 % \begin{macrocode}
179 %</code>
180 % \end{macrocode}
181 %
182 % \end{implementation}
183 %
184 % \PrintIndex