summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx70
1 files changed, 36 insertions, 34 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx
index 728085952a1..fa3fe89a2ac 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx
@@ -22,7 +22,7 @@
%
%<*driver>
\documentclass[full]{l3doc}
-\GetIdInfo$Id: l3fp-convert.dtx 6805 2016-12-28 22:15:52Z joseph $
+\GetIdInfo$Id: l3fp-convert.dtx 6943 2017-02-17 16:47:59Z bruno $
{L3 Floating-point conversion}
\begin{document}
\DocInput{\jobname.dtx}
@@ -124,22 +124,21 @@
% \enquote{invalid_operation} exception. In the normal case,
% decrement the exponent and unbrace the $4$ brace groups, then in a
% second step grab the first digit (previously hidden in braces) to
-% order the various parts correctly. Finally trim zeros.
+% order the various parts correctly.
% \begin{macrocode}
\cs_new:Npn \@@_to_scientific_dispatch:w \s_@@ \@@_chk:w #1#2
{
\if_meaning:w 2 #2 \exp_after:wN - \exp:w \exp_end_continue_f:w \fi:
\if_case:w #1 \exp_stop_f:
- \@@_case_return:nw { 0 }
+ \@@_case_return:nw { 0.000000000000000e0 }
\or: \exp_after:wN \@@_to_scientific_normal:wnnnnn
\or:
\@@_case_use:nw
{
- \@@_invalid_operation:nnw
+ \exp_args:Nf \@@_invalid_operation:nnw
{
- \exp_after:wN 1
- \exp_after:wN e
- \int_use:N \c_@@_max_exponent_int
+ \@@_expand:n
+ { { 1.000000000000000e } \int_use:N \c_@@_max_exponent_int }
}
{ fp_to_scientific }
}
@@ -147,7 +146,7 @@
\@@_case_use:nw
{
\@@_invalid_operation:nnw
- { 0 }
+ { 0.000000000000000e0 }
{ fp_to_scientific }
}
\fi:
@@ -156,17 +155,13 @@
\cs_new:Npn \@@_to_scientific_normal:wnnnnn
\s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 ;
{
- \if_int_compare:w #2 = \c_one
- \exp_after:wN \@@_to_scientific_normal:wNw
- \else:
- \exp_after:wN \@@_to_scientific_normal:wNw
- \exp_after:wN e
- \__int_value:w \__int_eval:w #2 - \c_one
- \fi:
+ \exp_after:wN \@@_to_scientific_normal:wNw
+ \exp_after:wN e
+ \__int_value:w \__int_eval:w #2 - 1
; #3 #4 #5 #6 ;
}
\cs_new:Npn \@@_to_scientific_normal:wNw #1 ; #2#3;
- { \@@_trim_zeros:w #2.#3 ; #1 }
+ { #2.#3 #1 }
% \end{macrocode}
% \end{macro}
%
@@ -239,17 +234,17 @@
\cs_new:Npn \@@_to_decimal_normal:wnnnnn
\s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 ;
{
- \int_compare:nNnTF {#2} > \c_zero
+ \int_compare:nNnTF {#2} > 0
{
- \int_compare:nNnTF {#2} < \c_sixteen
+ \int_compare:nNnTF {#2} < \c_@@_prec_int
{
- \@@_decimate:nNnnnn { \c_sixteen - #2 }
+ \@@_decimate:nNnnnn { \c_@@_prec_int - #2 }
\@@_to_decimal_large:Nnnw
}
{
\exp_after:wN \exp_after:wN
\exp_after:wN \@@_to_decimal_huge:wnnnn
- \prg_replicate:nn { #2 - \c_sixteen } { 0 } ;
+ \prg_replicate:nn { #2 - \c_@@_prec_int } { 0 } ;
}
{#3} {#4} {#5} {#6}
}
@@ -264,7 +259,7 @@
\cs_new:Npn \@@_to_decimal_large:Nnnw #1#2#3#4;
{
\exp_after:wN \@@_trim_zeros:w \__int_value:w
- \if_int_compare:w #2 > \c_zero
+ \if_int_compare:w #2 > 0 \exp_stop_f:
#2
\fi:
\exp_stop_f:
@@ -290,7 +285,11 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux, EXP]{\@@_to_tl_dispatch:w, \@@_to_tl_normal:nnnnn}
+% \begin{macro}[aux, EXP]
+% {
+% \@@_to_tl_dispatch:w, \@@_to_tl_normal:nnnnn,
+% \@@_to_tl_scientific:wnnnnn, \@@_to_tl_scientific:wNw
+% }
% A structure similar to \cs{@@_to_scientific_dispatch:w} and
% \cs{@@_to_decimal_dispatch:w}, but without the \enquote{invalid operation}
% exception. First filter special cases. We express normal numbers
@@ -309,19 +308,22 @@
}
\cs_new:Npn \@@_to_tl_normal:nnnnn #1
{
- \if_int_compare:w #1 > \c_sixteen
- \exp_after:wN \@@_to_scientific_normal:wnnnnn
- \else:
- \if_int_compare:w #1 < - \c_two
- \exp_after:wN \exp_after:wN
- \exp_after:wN \@@_to_scientific_normal:wnnnnn
- \else:
- \exp_after:wN \exp_after:wN
- \exp_after:wN \@@_to_decimal_normal:wnnnnn
- \fi:
- \fi:
+ \int_compare:nTF
+ { -2 <= #1 <= \c_@@_prec_int }
+ { \@@_to_decimal_normal:wnnnnn }
+ { \@@_to_tl_scientific:wnnnnn }
\s_@@ \@@_chk:w 1 0 {#1}
}
+\cs_new:Npn \@@_to_tl_scientific:wnnnnn
+ \s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 ;
+ {
+ \exp_after:wN \@@_to_tl_scientific:wNw
+ \exp_after:wN e
+ \__int_value:w \__int_eval:w #2 - 1
+ ; #3 #4 #5 #6 ;
+ }
+\cs_new:Npn \@@_to_tl_scientific:wNw #1 ; #2#3;
+ { \@@_trim_zeros:w #2.#3 ; #1 }
% \end{macrocode}
% \end{macro}
%
@@ -411,7 +413,7 @@
\@@_case_return:nw { \exp_after:wN \c_zero_fp }
\else:
\exp_after:wN \@@_from_dim:wNw
- \__int_value:w \__int_eval:w #1 - \c_four
+ \__int_value:w \__int_eval:w #1 - 4
\if_meaning:w - #2
\exp_after:wN , \exp_after:wN 2 \__int_value:w
\else: