% \iffalse % %% File l3fp-types.dtx (C) Copyright 2012-2015,2017,2018,2020,2021,2023 The LaTeX 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 % % http://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]{l3doc} \usepackage{amsmath} \begin{document} \DocInput{\jobname.dtx} \end{document} % % \fi % % \title{^^A % The \pkg{l3fp-types} module\\ Floating point types^^A % } % % \author{^^A % The \LaTeX{} Project\thanks % {^^A % E-mail: % \href{mailto:latex-team@latex-project.org} % {latex-team@latex-project.org}^^A % }^^A % } % % \date{Released 2024-03-14} % % \maketitle % % \begin{documentation} % % \end{documentation} % % \begin{implementation} % % \section{\pkg{l3fp-types} implementation} % % \begin{macrocode} %<*package> % \end{macrocode} % % \begin{macrocode} %<@@=fp> % \end{macrocode} % % \subsection{Support for types} % % Despite lack of documentation, the \pkg{l3fp} internals support types. % Each additional type must define % \begin{itemize} % \item |\s__fp_|\meta{type} and |\__fp_|\meta{type}|_chk:w|; % \item |\__fp_exp_after_|\meta{type}|_f:nw|; % \item |\__fp_|\meta{type}|_to_|\meta{out}|:w| for \meta{out} among % |decimal|, |scientific|, |tl|; % \end{itemize} % and may define % \begin{itemize} % \item |\__fp_|\meta{type}|_to_int:w| and |\__fp_|\meta{type}|_to_dim:w|; % \item |\__fp_|\meta{op}|_|\meta{type}|_o:w| for any of the \meta{op} % that the type implements, among |acos|, |acsc|, |asec|, |asin|, % |cos|, |cot|, |csc|, |exp|, |ln|, |not|, |sec|, |set_sign|, |sin|, % |tan|; % \item |\__fp_|\meta{type_1}|_|\meta{op}|_|\meta{type_2}|_o:ww| for % \meta{op} among |^*/-+&|\verb"|" and for every pair of types; % \item |\__fp_|\meta{type_1}|_bcmp_|\meta{type_2}|:ww| for every % pair of types. % \end{itemize} % The latter is set up in \pkg{l3fp-logic}. % % \subsection{Dispatch according to the type} % % \begin{macro}[EXP] % {\@@_types_cs_to_op:N, \@@_types_cs_to_op_auxi:wwwn} % From |\__fp_|\meta{op}|_o:w| produce \meta{op}, otherwise~|?|. % \begin{macrocode} \cs_new:Npe \@@_types_cs_to_op:N #1 { \exp_not:N \exp_after:wN \exp_not:N \@@_types_cs_to_op_auxi:wwwn \exp_not:N \token_to_str:N #1 \s_@@_mark \exp_not:N \@@_use_i_delimit_by_s_stop:nw \tl_to_str:n { @@_ _o:w } \s_@@_mark { \exp_not:N \@@_use_i_delimit_by_s_stop:nw ? } \s_@@_stop } \use:e { \cs_new:Npn \exp_not:N \@@_types_cs_to_op_auxi:wwwn #1 \tl_to_str:n { @@_ } #2 \tl_to_str:n { _o:w } #3 \s_@@_mark #4 { #4 {#2} } } % \end{macrocode} % \end{macro} % % \begin{macro}[EXP]{\@@_types_unary:NNw} % \begin{macro}[EXP] % {\@@_types_unary_auxi:nNw, \@@_types_unary_auxii:NnNw} % \begin{syntax} % \cs{@@_types_unary:NNw} |\__fp_|\meta{function}|_o:w| % ~~\meta{token} \meta{operand} |@| % \end{syntax} % \begin{macrocode} \cs_new:Npn \@@_types_unary:NNw #1 { \exp_args:Nf \@@_types_unary_auxi:nNw { \@@_types_cs_to_op:N #1 } } \cs_new:Npn \@@_types_unary_auxi:nNw #1#2#3 { \exp_after:wN \@@_types_unary_auxii:NnNw \cs:w @@_#1 \@@_type_from_scan:N #3 _o:w \cs_end: {#1} #2#3 } \cs_new:Npn \@@_types_unary_auxii:NnNw #1#2#3 { \token_if_eq_meaning:NNTF \scan_stop: #1 { \@@_invalid_operation_o:nw {#2} } { #1 #3 } } % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}[EXP]{\@@_types_binary:Nww} % \begin{macro}[EXP] % {\@@_types_binary_auxi:Nww, \@@_types_binary_auxii:NNww} % \begin{syntax} % \cs{@@_types_binary:Nww} |\__fp_|\meta{binop}|_o:ww| % ~~\meta{operand_1} \meta{operand_2} |@| % \end{syntax} % \begin{macrocode} \cs_new:Npn \@@_types_binary:Nww #1 { \exp_last_unbraced:Nf \@@_types_binary_auxi:Nww { \@@_types_cs_to_op:N #1 } } \cs_new:Npn \@@_types_binary_auxi:Nww #1#2#3; #4#5; @ { \exp_after:wN \@@_types_binary_auxii:NNww \cs:w @@ \@@_type_from_scan:N #2 _#1 \@@_type_from_scan:N #4 _o:ww \cs_end: #1 #2#3; #4#5; } \cs_new:Npn \@@_types_binary_auxii:NNww #1#2 { \token_if_eq_meaning:NNTF \scan_stop: #1 { \@@_invalid_operation_o:Nww #2 } {#1} } % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macrocode} % % \end{macrocode} % % \end{implementation} % % \PrintIndex