diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx index 10cf4d2d03b..7b7e11bd20f 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3fp-convert.dtx Copyright(C) 2011-2012 The LaTeX3 Project +%% File: l3fp-convert.dtx Copyright(C) 2011-2013 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 @@ -36,7 +36,7 @@ % %<*driver> \RequirePackage{l3bootstrap} -\GetIdInfo$Id: l3fp-convert.dtx 4339 2012-11-24 19:16:43Z joseph $ +\GetIdInfo$Id: l3fp-convert.dtx 4601 2013-11-18 23:13:28Z bruno $ {L3 Floating-point conversion} \documentclass[full]{l3doc} \begin{document} @@ -402,10 +402,10 @@ % \begin{macro}[EXP]{\dim_to_fp:n} % \begin{macro}[aux, EXP] % { -% \@@_from_dim_test:N, -% \@@_from_dim:Nw, +% \@@_from_dim_test:ww, +% \@@_from_dim:wNw, % \@@_from_dim:wNNnnnnnn, -% \@@_from_dim:wnnnnwN, +% \@@_from_dim:wnnnnwNw, % } % The dimension expression (which can in fact be a glue expression) is % evaluated, converted to a number (\emph{i.e.}, expressed in scaled @@ -413,40 +413,48 @@ % value expressed in points. The auxiliary \cs{@@_mul_npos_o:Nww} % expects the desired \meta{final sign} and two floating point % operands (of the form \cs{s_@@} \ldots{} |;|) as arguments. +% This set of functions is also used to convert dimension registers to +% floating points while parsing expressions: in this context there is +% an additional exponent, which is the first argument of +% \cs{@@_from_dim_test:ww}, and is combined with the exponent $-4$ +% of $2^{-16}$. There is also a need to expand afterwards: this is +% performed by \cs{@@_mul_npos_o:Nww}, and cancelled by +% \cs{prg_do_nothing:} in \cs{dim_to_fp:n}. % \begin{macrocode} \cs_new:Npn \dim_to_fp:n #1 { - \exp_after:wN \@@_from_dim_test:N + \exp_after:wN \@@_from_dim_test:ww + \exp_after:wN 0 + \exp_after:wN , \__int_value:w \etex_glueexpr:D #1 ; } -\cs_new:Npn \@@_from_dim_test:N #1 +\cs_new:Npn \@@_from_dim_test:ww #1, #2 { - \if_meaning:w 0 #1 - \@@_case_return:nw \c_zero_fp + \if_meaning:w 0 #2 + \@@_case_return:nw { \exp_after:wN \c_zero_fp } \else: - \if_meaning:w - #1 - \exp_after:wN \@@_from_dim:Nw - \exp_after:wN 2 - \__int_value:w - \else: - \exp_after:wN \@@_from_dim:Nw - \exp_after:wN 0 - \__int_value:w #1 - \fi: + \exp_after:wN \@@_from_dim:wNw + \int_use:N \__int_eval:w #1 - \c_four + \if_meaning:w - #2 + \exp_after:wN , \exp_after:wN 2 \__int_value:w + \else: + \exp_after:wN , \exp_after:wN 0 \__int_value:w #2 + \fi: \fi: } -\cs_new:Npn \@@_from_dim:Nw #1 #2; +\cs_new:Npn \@@_from_dim:wNw #1,#2#3; { \@@_pack_twice_four:wNNNNNNNN \@@_from_dim:wNNnnnnnn ; - #2 000 0000 00 {10}987654321; #1 + #3 000 0000 00 {10}987654321; #2 {#1} } \cs_new:Npn \@@_from_dim:wNNnnnnnn #1; #2#3#4#5#6#7#8#9 - { \@@_from_dim:wnnnnwN #1 {#2#300} {0000} ; } -\cs_new:Npn \@@_from_dim:wnnnnwN #1; #2#3#4#5#6; #7 + { \@@_from_dim:wnnnnwNn #1 {#2#300} {0000} ; } +\cs_new:Npn \@@_from_dim:wnnnnwNn #1; #2#3#4#5#6; #7#8 { \@@_mul_npos_o:Nww #7 \s_@@ \@@_chk:w 1 #7 {#5} #1 ; - \s_@@ \@@_chk:w 1 0 {-4} {1525} {8789} {0625} {0000} ; + \s_@@ \@@_chk:w 1 0 {#8} {1525} {8789} {0625} {0000} ; + \prg_do_nothing: } % \end{macrocode} % \end{macro} |