summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/siunitx/siunitx-number.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-09-01 03:01:08 +0000
committerNorbert Preining <norbert@preining.info>2023-09-01 03:01:08 +0000
commita6340ee3ba0294ecd24259d39642d27d804187b2 (patch)
treecc82e5c3e6d1b796a6f2a530aea279ff238b556c /macros/latex/contrib/siunitx/siunitx-number.dtx
parent7cda3a1cc32bd43dab837e2b73046dab2aeaec98 (diff)
CTAN sync 202309010301
Diffstat (limited to 'macros/latex/contrib/siunitx/siunitx-number.dtx')
-rw-r--r--macros/latex/contrib/siunitx/siunitx-number.dtx458
1 files changed, 269 insertions, 189 deletions
diff --git a/macros/latex/contrib/siunitx/siunitx-number.dtx b/macros/latex/contrib/siunitx/siunitx-number.dtx
index 5bba843ce6..2218e61022 100644
--- a/macros/latex/contrib/siunitx/siunitx-number.dtx
+++ b/macros/latex/contrib/siunitx/siunitx-number.dtx
@@ -94,8 +94,8 @@
% \end{quote}
% where the two sign parts must be single tokens if present,
% and all other components
-% must be given in braces. The number will have at least one digit for both the
-% \meta{integer} and \meta{exponent} parts: these are required. The
+% must be given in braces. The number will have at least one digit for either the
+% \meta{integer} and \meta{exponent} parts.. The
% \meta{uncertainty} part should either be blank or contain an
% \meta{identifier} (as a brace group), followed by one or more data entries.
% Valid uncertainty \meta{identifiers} currently are
@@ -115,7 +115,7 @@
% \cs{empty}.
% \end{function}
%
-% \begin{function}{\siunitx_number_process:NN}
+% \begin{function}{\siunitx_number_process:NN, \siunitx_number_process:cc}
% \begin{syntax}
% \cs{siunitx_number_process:N} \meta{tl~var1} \meta{tl~var2}
% \end{syntax}
@@ -131,10 +131,12 @@
% with the result stored in \meta{tl~var2}.
% \end{function}
%
-% \begin{function}[rEXP]
+% \begin{function}[EXP]
% {
-% \siunitx_number_output:N, \siunitx_number_output:n,
-% \siunitx_number_output:NN, \siunitx_number_output:nN
+% \siunitx_number_output:N, \siunitx_number_output:c
+% \siunitx_number_output:n,
+% \siunitx_number_output:NN, \siunitx_number_output:cN
+% \siunitx_number_output:nN
% }
% \begin{syntax}
% \cs{siunitx_number_output:N} \meta{number}
@@ -179,7 +181,8 @@
% \begin{function}[EXP]
% {
% \siunitx_number_adjust_exponent:Nn ,
-% \siunitx_number_adjust_exponent:nn
+% \siunitx_number_adjust_exponent:nn ,
+% \siunitx_number_adjust_exponent:Vn
% }
% \begin{syntax}
% \cs{siunitx_number_adjust_exponent:Nn} \meta{number} \Arg{fp~expr}
@@ -711,7 +714,7 @@
% Variants not provided by \pkg{expl3}.
% \begin{macrocode}
\cs_generate_variant:Nn \keys_set:nn { nx }
-\cs_generate_variant:Nn \tl_if_blank:nTF { f }
+\cs_generate_variant:Nn \tl_if_blank:nTF { e }
\cs_generate_variant:Nn \tl_if_in:NnTF { NV }
\cs_generate_variant:Nn \tl_if_in:nnTF { nV }
\cs_generate_variant:Nn \tl_remove_all:Nn { NV }
@@ -799,8 +802,6 @@
% \end{quote}
% where all components must be given in braces. \emph{All} of the components
% must be present in a stored number (\foreign{i.e.}~at the end of parsing).
-% The number must have at least one digit for both the \meta{integer} and
-% \meta{exponent} parts.
%
% A non-empty \meta{uncertainty} must contain one leading brace group
% containing an identifier, then zero or more brace groups which contain
@@ -1078,7 +1079,7 @@
\tl_put_right:NV \l_@@_uncert_tl \l_@@_flex_tl
\tl_if_empty:NF \l_@@_uncert_tl
{
- \tl_if_blank:fTF { \exp_after:wN \use_iv:nnnn \l_@@_parsed_tl }
+ \tl_if_blank:eTF { \exp_after:wN \use_iv:nnnn \l_@@_parsed_tl }
{ \@@_parse_combine_uncert: }
{ \tl_clear:N \l_@@_parsed_tl }
}
@@ -1098,11 +1099,21 @@
% \begin{macro}{\@@_parse_combine_uncert:}
% \begin{macro}[EXP]{\@@_parse_combine_uncert:nnnn}
% \begin{macro}[EXP]{\@@_parse_combine_uncert:nn}
-% \begin{macro}[EXP]{\@@_parse_combine_uncert_loop:nnnnnnn}
-% \begin{macro}[EXP]{\@@_parse_combine_uncert:nnnnnn}
-% \begin{macro}[EXP]{\@@_parse_combine_uncert:nnnnnnn}
+% \begin{macro}[EXP]
+% {
+% \@@_parse_combine_uncert_loop:nnnnnnn ,
+% \@@_parse_combine_uncert_loop:nnnnnnn
+% }
+% \begin{macro}[EXP]
+% {\@@_parse_combine_uncert:nnnnnn, \@@_parse_combine_uncert:ennnnn}
+% \begin{macro}[EXP]
+% {\@@_parse_combine_uncert:nnnnnnn, \@@_parse_combine_uncert:ennnnnn}
% \begin{macro}[EXP]{\@@_parse_combine_uncert:nnnnn}
-% \begin{macro}[EXP]{\@@_parse_combine_uncert_aux:nnnn}
+% \begin{macro}[EXP]
+% {
+% \@@_parse_combine_uncert_aux:nnnn ,
+% \@@_parse_combine_uncert_aux:eenn
+% }
% \begin{macro}[EXP]{\@@_parse_combine_uncert:N}
% \begin{macro}[EXP]{\@@_parse_combine_uncert:w}
% \begin{macro}[EXP]{\@@_parse_combine_uncert_end:nnn}
@@ -1148,10 +1159,11 @@
{
\quark_if_recursion_tail_stop_do:nn {#4}
{ \@@_parse_combine_uncert_end:nnn {#1} {#2} {#3} }
- \exp_args:Nf \@@_parse_combine_uncert:nnnnnn
+ \@@_parse_combine_uncert:ennnnn
{ \int_eval:n { \tl_count:n {#1} - \tl_count:n {#6} } }
{#1} {#2} {#3} {#5} {#6}
}
+\cs_generate_variant:Nn \@@_parse_combine_uncert_loop:nnnnnnn { nee }
% \end{macrocode}
% The difference in places between the two decimal parts is now found: this
% is done just once to avoid having to parse token lists twice. The value
@@ -1160,10 +1172,11 @@
% \begin{macrocode}
\cs_new:Npn \@@_parse_combine_uncert:nnnnnn #1
{
- \exp_args:Nf \@@_parse_combine_uncert:nnnnnnn
+ \@@_parse_combine_uncert:ennnnnn
{ \prg_replicate:nn { \int_abs:n {#1} } { 0 } }
{#1}
}
+\cs_generate_variant:Nn \@@_parse_combine_uncert:nnnnnn { e }
\cs_new:Npn \@@_parse_combine_uncert:nnnnnnn #1#2#3#4#5#6#7
{
\int_compare:nNnTF {#2} > 0
@@ -1176,6 +1189,7 @@
{ #3 #1 } {#4} {#5} {#6} {#7}
}
}
+\cs_generate_variant:Nn \@@_parse_combine_uncert:nnnnnnn { e }
% \end{macrocode}
% We now ensure that the decimal part is never entirely blank \emph{if} there
% are decimal-part uncertainty digits. There is also a need to handle the
@@ -1184,7 +1198,7 @@
% \begin{macrocode}
\cs_new:Npn \@@_parse_combine_uncert:nnnnn #1#2#3#4#5
{
- \exp_args:Nee \@@_parse_combine_uncert_aux:nnnn
+ \@@_parse_combine_uncert_aux:eenn
{
\bool_lazy_and:nnTF
{ \tl_if_blank_p:n {#1} }
@@ -1201,8 +1215,8 @@
}
\cs_new:Npn \@@_parse_combine_uncert_aux:nnnn #1#2#3#4
{
- \exp_args:Neee \@@_parse_combine_uncert_loop:nnnnnnn
- { \exp_not:n {#1} }
+ \@@_parse_combine_uncert_loop:neennnn
+ {#1}
{
\exp_not:n {#3}
\tl_if_blank:nF {#2} { S }
@@ -1212,6 +1226,7 @@
\tl_if_blank:nF {#2} { { \exp_not:n {#2} } }
}
}
+\cs_generate_variant:Nn \@@_parse_combine_uncert_aux:nnnn { ee }
% \end{macrocode}
% A short routine to remove any leading zeros in the uncertainty part,
% which are not needed for the compact representation used by the module.
@@ -1309,7 +1324,7 @@
{
\tl_if_empty:NTF \l_siunitx_number_input_exponent_tl
{
- \tl_set:Nn \l_@@_exponent_tl { { } 0 }
+ \tl_set:Nn \l_@@_exponent_tl { { } { } }
\tl_if_empty:NF \l_@@_parsed_tl
{ \@@_parse_loop: }
}
@@ -1343,7 +1358,7 @@
\cs_new_protected:Npn \@@_parse_exponent_auxii:nn #1#2
{
\quark_if_nil:nTF {#2}
- { \tl_set:Nn \l_@@_exponent_tl { { } 0 } }
+ { \tl_set:Nn \l_@@_exponent_tl { { } { } } }
{
\tl_set:Nn \l_@@_arg_tl {#1}
\tl_if_blank:nTF {#2}
@@ -1669,7 +1684,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_parse_loop_after_decimal:NN #1#2
{
- \tl_if_blank:fTF { \exp_after:wN \use_none:n #1 }
+ \tl_if_blank:eTF { \exp_after:wN \use_none:n #1 }
{
\quark_if_recursion_tail_stop_do:Nn #2
{ \@@_parse_loop_break:w \q_recursion_stop }
@@ -1759,7 +1774,11 @@
% \begin{macro}{\@@_parse_uncert_marker:w}
% \begin{macro}{\@@_parse_uncert_marker:nnnnN}
% \begin{macro}{\@@_parse_uncert_marker:nnnnnN}
-% \begin{macro}{\@@_parse_uncert_marker:nnnnnnN}
+% \begin{macro}
+% {
+% \@@_parse_uncert_marker:nnnnnnN ,
+% \@@_parse_uncert_marker:xnnnnnN
+% }
% \begin{macro}{\@@_parse_uncert_after:N}
% Parsing a combined uncertainty has a very restricted range of allowed
% tokens. A closing uncertainty token in the first place is an error,
@@ -1935,7 +1954,7 @@
}
\cs_new_protected:Npn \@@_parse_uncert_marker:nnnnnN #1#2#3#4#5#6
{
- \exp_args:Ne \@@_parse_uncert_marker:nnnnnnN
+ \@@_parse_uncert_marker:xnnnnnN
{ \int_eval:n { \tl_count:n {#4} } }
{#1} {#2} {#3} {#4} {#5} #6
}
@@ -1971,6 +1990,7 @@
}
#5#6#7
}
+\cs_generate_variant:Nn \@@_parse_uncert_marker:nnnnnnN { x }
% \end{macrocode}
% At the end of collection, we can either start another one or be done:
% either way we move the data around.
@@ -2177,7 +2197,7 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\siunitx_number_process:NN}
+% \begin{macro}{\siunitx_number_process:NN, \siunitx_number_process:cc}
% \begin{macro}{\@@_process:nnnnnnnNN}
% A top-level interface for the processing tools. Rounding happens in all
% cases, but exponents are only processed if the value is not $0$.
@@ -2194,6 +2214,7 @@
\@@_digits:NN #2 #2
}
}
+\cs_generate_variant:Nn \siunitx_number_process:NN { cc }
\cs_new_protected:Npn \@@_process:nnnnnnnNN #1#2#3#4#5#6#7#8#9
{
\bool_lazy_and:nnTF
@@ -2215,35 +2236,34 @@
% \begin{macro}{\@@_exponent:NN}
% \begin{macro}[EXP]
% {
+% \@@_exponent:nnnnnnn ,
+% \@@_exponent_aux:nnnnnnn ,
% \@@_exponent_engineering:nnnnnnn ,
% \@@_exponent_fixed:nnnnnnn ,
-% \@@_exponent_input:nnnnnnn ,
% \@@_exponent_scientific:nnnnnnn
% }
% \begin{macro}[EXP]
% {
-% \@@_exponent_fixed:nnnnnnnn ,
-% \@@_exponent_scientific:nnnnnnnn
+% \@@_exponent_fixed:nnnnnnnn ,
+% \@@_exponent_fixed:ennnnnnn ,
+% \@@_exponent_scientific:nnnnnnnn ,
+% \@@_exponent_scientific:ennnnnnn
% }
% \begin{macro}[EXP]{\@@_exponent_scientific:nnnw}
-% \begin{macro}[EXP]{\@@_exponent_shift:nnn,\@@_exponent_shift:nnf}
+% \begin{macro}[EXP]{\@@_exponent_shift:nnn, \@@_exponent_shift:nne}
% \begin{macro}[EXP]{\@@_exponent_shift_down:nnnw}
% \begin{macro}[EXP]{\@@_exponent_shift_down:nnn}
% \begin{macro}[EXP]{\@@_exponent_shift_down:nw}
% \begin{macro}[EXP]{\@@_exponent_shift_up:nnn}
% \begin{macro}[EXP]{\@@_exponent_shift_up:nnw}
% \begin{macro}[EXP]
-% {
-% \@@_exponent_shift_up_aux:nnn ,
-% \@@_exponent_shift_up_aux:fnn ,
-% \@@_exponent_shift_up_aux:ffn
-% }
+% {\@@_exponent_shift_up_aux:nnn, \@@_exponent_shift_up_aux:een}
% \begin{macro}[EXP]{\@@_exponent_shift_uncert:nw}
% \begin{macro}[EXP]
-% {\@@_exponent_shift_uncert_S:nnnn, \@@_exponent_shift_uncert_S:fnnn}
+% {\@@_exponent_shift_uncert_S:nnnn, \@@_exponent_shift_uncert_S:ennn}
% \begin{macro}[EXP]{\@@_exponent_uncert:n}
% \begin{macro}[EXP]{\@@_exponent_finalise:n}
-% \begin{macro}[EXP]{\@@_exponent_engineering_aux:nnnnnnn}
+% \begin{macro}[EXP]{\@@_exponentcd te_engineering_aux:nnnnnnn}
% \begin{macro}[EXP]
% {
% \@@_exponent_engineering_0:nnnn ,
@@ -2254,7 +2274,7 @@
% \begin{macro}[EXP]{\@@_exponent_engineering_uncert:nn}
% \begin{macro}[EXP]{\@@_exponent_engineering_uncert_S:nnn}
% \begin{macro}[EXP]{\@@_exponent_threshold:nnnnnnn}
-% \begin{macro}[EXP]{\@@_exponent_threshold:nn}
+% \begin{macro}[EXP]{\@@_exponent_threshold:nn, \@@_exponent_threshold:en}
% \begin{macro}[EXP]{\@@_exponent_threshold:nnnnnnnn}
% Manipulating an exponent is done using a single expansion function
% \emph{unless} dealing with engineering-style output. The latter is easier
@@ -2265,21 +2285,31 @@
\cs_new_protected:Npn \@@_exponent:NN #1#2
{
\tl_set:Nx #2
- {
- \cs:w
- @@_exponent_ \l_@@_exponent_mode_tl :nnnnnnn
- \exp_after:wN
- \cs_end: #1
- }
+ { \exp_after:wN \@@_exponent:nnnnnnn #1 }
\str_if_eq:VnT \l_@@_exponent_mode_tl { engineering }
{
\tl_set:Nx #2
{ \exp_after:wN \@@_exponent_engineering_aux:nnnnnnn #2 }
}
}
+\cs_new:Npn \@@_exponent:nnnnnnn #1#2#3#4#5#6#7
+ {
+ \str_if_eq:VnTF \l_@@_exponent_mode_tl { input }
+ { \exp_not:n { {#1} {#2} {#3} {#4} {#5} {#6} {#7} } }
+ {
+ \tl_if_blank:nTF {#7}
+ { \@@_exponent_aux:nnnnnnn {#1} {#2} {#3} {#4} {#5} {#6} { 0 } }
+ { \@@_exponent_aux:nnnnnnn {#1} {#2} {#3} {#4} {#5} {#6} {#7} }
+ }
+ }
+\cs_new:Npn \@@_exponent_aux:nnnnnnn #1#2#3#4#5#6#7
+ {
+ \use:c { @@_exponent_ \l_@@_exponent_mode_tl :nnnnnnn }
+ {#1} {#2} {#3} {#4} {#5} {#6} {#7}
+ }
\cs_new:Npn \@@_exponent_fixed:nnnnnnn #1#2#3#4#5#6#7
{
- \exp_args:Nf \@@_exponent_fixed:nnnnnnnn
+ \@@_exponent_fixed:ennnnnnn
{ \int_eval:n { \l_@@_exponent_fixed_int - (#6#7) } }
{#1} {#2} {#3} {#4} {#5} {#6} {#7}
}
@@ -2291,8 +2321,7 @@
{ \int_compare:nNnT \l_@@_exponent_fixed_int < 0 { - } }
{ \int_abs:n \l_@@_exponent_fixed_int }
}
-\cs_new:Npn \@@_exponent_input:nnnnnnn #1#2#3#4#5#6#7
- { \exp_not:n { {#1} {#2} {#3} {#4} {#5} {#6} {#7} } }
+\cs_generate_variant:Nn \@@_exponent_fixed:nnnnnnnn { e }
% \end{macrocode}
% To convert to scientific notation, the key question is to find the number
% of significant places. That is easy enough if the number has a non-zero
@@ -2301,7 +2330,7 @@
% \begin{macrocode}
\cs_new:Npn \@@_exponent_scientific:nnnnnnn #1#2#3#4#5#6#7
{
- \exp_args:Nf \@@_exponent_scientific:nnnnnnnn
+ \@@_exponent_scientific:ennnnnnn
{ \int_eval:n { \tl_count:n {#3} } }
{#1} {#2} {#3} {#4} {#5} {#6} {#7}
}
@@ -2323,6 +2352,7 @@
\@@_exponent_finalise:n { #1 + #7#8 - 1 }
}
}
+\cs_generate_variant:Nn \@@_exponent_scientific:nnnnnnnn { e }
\cs_new_eq:NN \@@_exponent_engineering:nnnnnnn
\@@_exponent_scientific:nnnnnnn
\cs_new:Npn \@@_exponent_scientific:nnnw #1#2#3#4#5 \q_stop
@@ -2351,7 +2381,7 @@
{ {#2} {#3} }
}
}
-\cs_generate_variant:Nn \@@_exponent_shift:nnn { nnf }
+\cs_generate_variant:Nn \@@_exponent_shift:nnn { nne }
% \end{macrocode}
% For shifting the exponent down, there is first a loop to reserve the
% integer part before doing the work: that of course has to be undone
@@ -2385,7 +2415,7 @@
{
\tl_if_blank:nTF {#3}
{
- \@@_exponent_shift_up_aux:ffn
+ \@@_exponent_shift_up_aux:een
{ \int_eval:n { #1 + 1 } }
{ \str_if_eq:nnF {#2} { 0 } {#2} 0 }
{ }
@@ -2395,7 +2425,7 @@
}
\cs_new:Npn \@@_exponent_shift_up:nnw #1#2#3#4 \q_stop
{
- \@@_exponent_shift_up_aux:ffn
+ \@@_exponent_shift_up_aux:een
{ \int_eval:n { #1 + 1 } }
{ \str_if_eq:nnF {#2} { 0 } {#2} #3 }
{#4}
@@ -2417,7 +2447,7 @@
{ \@@_exponent_shift_up:nnn {#1} {#2} {#3} }
}
}
-\cs_generate_variant:Nn \@@_exponent_shift_up_aux:nnn { f , ff }
+\cs_generate_variant:Nn \@@_exponent_shift_up_aux:nnn { ee }
% \end{macrocode}
% If the shift has put digits into the integer part, we have to adjust the
% uncertainty accordingly. First, we grab the data, then adjust by the
@@ -2438,7 +2468,7 @@
\@@_exponent_uncert:n { { S } { 0 } }
}
{
- \use:c { @@_exponent_shift_uncert_ \use_i:nn #3 :fnnn }
+ \@@_exponent_shift_uncert_S:ennn
{ \prg_replicate:nn {#1} { 0 } }
{#2}
#3
@@ -2450,7 +2480,7 @@
#2
\@@_exponent_uncert:n { { S } { #4#1 } }
}
-\cs_generate_variant:Nn \@@_exponent_shift_uncert_S:nnnn { f }
+\cs_generate_variant:Nn \@@_exponent_shift_uncert_S:nnnn { e }
\cs_new:Npn \@@_exponent_uncert:n #1 { { \exp_not:n {#1} } }
% \end{macrocode}
% Tidy up the exponent to put the sign in the right place.
@@ -2503,7 +2533,7 @@
}
{
{ \exp_not:n {#1} \exp_not:o { \tl_head:w #2 \q_stop } }
- { \exp_not:f { \tl_tail:n {#2} } }
+ { \tl_tail:n {#2} }
{ \exp_not:n {#3} }
}
\@@_exponent_finalise:n { #4 - 1 }
@@ -2527,7 +2557,7 @@
}
{
{ \exp_not:n {#1#3} \exp_not:o { \tl_head:w #4 \q_stop } }
- { \exp_not:f { \tl_tail:n {#4} } }
+ { \tl_tail:n {#4} }
{ \exp_not:n {#2} }
}
}
@@ -2552,16 +2582,17 @@
% \begin{macrocode}
\cs_new:Npn \@@_exponent_threshold:nnnnnnn #1#2#3#4#5#6#7
{
- \exp_args:Ne \@@_exponent_threshold:nn
+ \@@_exponent_threshold:en
{
\@@_exponent_scientific:nnnnnnn
{#1} {#2} {#3} {#4} {#5} {#6} {#7}
}
{ {#1} {#2} {#3} {#4} {#5} {#6} {#7} }
}
-\cs_new:Npn \@@_exponent_threshold:nn #1#2
+\cs_new:Npn \@@_exponent_threshold:nn #1#2
{ \@@_exponent_threshold:nnnnnnnn #1 {#2} }
-\cs_new:Npn \@@_exponent_threshold:nnnnnnnn #1#2#3#4#5#6#7#8
+\cs_generate_variant:Nn \@@_exponent_threshold:nn { e }
+\cs_new:Npn \@@_exponent_threshold:nnnnnnnn #1#2#3#4#5#6#7#8
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn {#6#7} > \l_@@_lower_threshold_int }
@@ -2569,7 +2600,6 @@
{ \exp_not:n {#8} }
{ \exp_not:n { {#1} {#2} {#3} {#4} {#5} {#6} {#7} } }
}
-
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2751,25 +2781,39 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[EXP]{\@@_round:nnn, \@@_round:fnn}
+% \begin{macro}[EXP]{\@@_round:nnn, \@@_round:enn}
% \begin{macro}[EXP]{\@@_round:nnnn, \@@_round:Vnnn}
% \begin{macro}[EXP]
% {
% \@@_round_auxi:nnnnN ,
% \@@_round_auxii:nnnnN ,
% \@@_round_auxiii:nnnnN ,
-% \@@_round_auxiv:nnnnN
+% \@@_round_auxiii:ennnN ,
+% \@@_round_auxiv:nnnnN ,
+% \@@_round_auxiv:ennnN
% }
% \begin{macro}[EXP]{\@@_round_auxv:nnnN, \@@_round_auxvi:nnnN}
% \begin{macro}[EXP]{\@@_round_auxvii:nnnTF}
% \begin{macro}[EXP]{\@@_round_auxviii:nnN, \@@_round_auxix:nnN}
% \begin{macro}[EXP]{\@@_round_final_integer:nnw, \@@_round_final_decimal:nnw}
-% \begin{macro}[EXP]{\@@_round_final_signicant:n}
-% \begin{macro}[EXP]{\@@_round_final_signicant:N}
-% \begin{macro}[EXP]{\@@_round_final_signicant:w}
-% \begin{macro}[EXP]{\@@_round_final_output:nn, \@@_round_final_output:ff}
-% \begin{macro}[EXP]{\@@_round_final:nn, \@@_round_final:fn}
-% \begin{macro}[EXP]{\@@_round_final_shift:nn, \@@_round_final_shift:ff}
+% \begin{macro}[EXP]
+% {\@@_round_final_significant:n, \@@_round_final_significant:e}
+% \begin{macro}[EXP]{\@@_round_final_significant:N}
+% \begin{macro}[EXP]{\@@_round_final_significant:w}
+% \begin{macro}[EXP]
+% {
+% \@@_round_final_output:nn ,
+% \@@_round_final_output:ne ,
+% \@@_round_final_output:en ,
+% \@@_round_final_output:ee
+% }
+% \begin{macro}[EXP]{\@@_round_final:nn, \@@_round_final:en}
+% \begin{macro}[EXP]
+% {
+% \@@_round_final_shift:nn ,
+% \@@_round_final_shift:en ,
+% \@@_round_final_shift:ee
+% }
% \begin{macro}[EXP]{\@@_round_final_shift:Nw}
% \begin{macro}[EXP]
% {
@@ -2779,7 +2823,7 @@
% \@@_round_scientific:nn
% }
% \begin{macro}[EXP]{\@@_round_engineering:NNNNn}
-% \begin{macro}[EXP]{\@@_round_engineering:nnN}
+% \begin{macro}[EXP]{\@@_round_engineering:nnN, \@@_round_engineering:VnN}
% \begin{macro}[EXP]{\@@_round_truncate:n, \@@_round_truncate_direct:n}
% \begin{macro}[EXP]{\@@_round_truncate:nnN}
% Actually doing the rounding needs us to work from the least significant
@@ -2793,7 +2837,7 @@
\@@_round:Vnnn \l_@@_round_dir_tl
{#1} {#2} {#3}
}
-\cs_generate_variant:Nn \@@_round:nnn { f }
+\cs_generate_variant:Nn \@@_round:nnn { e }
\cs_new:Npn \@@_round:nnnn #1#2#3#4
{
\@@_round_auxi:nnnnN {#1} {#2} {#3} { }
@@ -2845,11 +2889,12 @@
}
\int_compare:nNnTF {#1} > 0
{
- \exp_args:Nf \@@_round_auxiii:nnnnN
+ \@@_round_auxiii:ennnN
{ \int_eval:n { #1 - 1 } } {#2} {#3} { #5#4 }
}
{ \@@_round_auxv:nnnN {#2} {#4} {#3} #5 }
}
+\cs_generate_variant:Nn \@@_round_auxiii:nnnnN { e }
\cs_new:Npn \@@_round_auxiv:nnnnN #1#2#3#4#5
{
\quark_if_recursion_tail_stop_do:Nn #5
@@ -2863,11 +2908,12 @@
}
\int_compare:nNnTF {#1} > 0
{
- \exp_args:Nf \@@_round_auxiv:nnnnN
+ \@@_round_auxiv:ennnN
{ \int_eval:n { #1 - 1 } } {#2} { #3 0 } { #5#4 }
}
{ \@@_round_auxvi:nnnN {#2} {#4} {#3} #5 }
}
+\cs_generate_variant:Nn \@@_round_auxiv:nnnnN { e }
% \end{macrocode}
% We now have the discarded digits, the matching filler and the
% next digit. So we can make the decision on rounding: that
@@ -2934,7 +2980,7 @@
{
\str_if_eq:nnTF {#1} { 0 }
{
- \@@_round_final_output:ff
+ \@@_round_final_output:ne
{ 1 }
{ \@@_round_truncate:n {#2} }
}
@@ -2961,7 +3007,7 @@
}
}
{
- \@@_round_final:fn
+ \@@_round_final:en
{ \int_eval:n { #3 + 1 } }
{ \@@_round_final_decimal:nnw {#1} {#2} }
}
@@ -2973,15 +3019,12 @@
{
\tl_if_blank:nTF {#1}
{
- \@@_round_final_shift:ff
- {
- \exp_last_unbraced:Nf 1
- { \@@_round_truncate_direct:n {#2} } 0
- }
+ \@@_round_final_shift:en
+ { 1 \@@_round_truncate_direct:n {#2} 0 }
{ }
}
{
- \@@_round_final_shift:ff
+ \@@_round_final_shift:ee
{ 1 #2 }
{ \@@_round_truncate:n {#1} }
}
@@ -2989,7 +3032,7 @@
\int_compare:nNnTF {#3} = 9
{ \@@_round_auxix:nnN {#1} { 0 #2 } }
{
- \@@_round_final:fn
+ \@@_round_final:en
{ \int_eval:n { #3 + 1 } }
{ \@@_round_final_integer:nnw {#1} {#2} }
}
@@ -3000,15 +3043,15 @@
\cs_new:Npn \@@_round_final_decimal:nnw
#1#2#3 \q_recursion_tail \q_recursion_stop
{
- \@@_round_final_output:ff
+ \@@_round_final_output:ee
{ \tl_reverse:n {#1} }
{ \tl_reverse:n {#3} #2 }
}
\cs_new:Npn \@@_round_final_integer:nnw
#1#2#3 \q_recursion_tail \q_recursion_stop
{
- \@@_round_final_output:ff
- { \exp_args:Ne \@@_round_final_significant:n { \tl_reverse:n {#3} #2 } }
+ \@@_round_final_output:en
+ { \@@_round_final_significant:e { \tl_reverse:n {#3} #2 } }
{#1}
}
\cs_new:Npn \@@_round_final_significant:n #1
@@ -3016,6 +3059,7 @@
\@@_round_final_significant:N #1
\q_recursion_tail \q_recursion_stop
}
+\cs_generate_variant:Nn \@@_round_final_significant:n { e }
\cs_new:Npn \@@_round_final_significant:N #1
{
\quark_if_recursion_tail_stop_do:Nn #1 { 0 }
@@ -3030,10 +3074,10 @@
#1 \q_recursion_tail \q_recursion_stop
{#1}
\cs_new:Npn \@@_round_final_output:nn #1#2 { {#1} {#2} }
-\cs_generate_variant:Nn \@@_round_final_output:nn { ff }
+\cs_generate_variant:Nn \@@_round_final_output:nn { ne , e , ee }
\cs_new:Npn \@@_round_final:nn #1#2
{ #2 #1 }
-\cs_generate_variant:Nn \@@_round_final:nn { f }
+\cs_generate_variant:Nn \@@_round_final:nn { e }
% \end{macrocode}
% Here we deal with the case where rounding applies along with an
% exponent set based on number of places. We can only get here if an
@@ -3055,7 +3099,7 @@
}
{ {#1} {#2} }
}
-\cs_generate_variant:Nn \@@_round_final_shift:nn { ff }
+\cs_generate_variant:Nn \@@_round_final_shift:nn { en , ee }
\cs_new:Npn \@@_round_engineering:nn #1#2
{
\int_compare:nNnTF { \tl_count:n {#1} } = 4
@@ -3072,7 +3116,7 @@
\cs_new:Npn \@@_round_engineering:NNNNn #1#2#3#4#5
{
{#1}
- \exp_args:NV \@@_round_engineering:nnN
+ \@@_round_engineering:VnN
\l_@@_round_precision_int { }
#2#3#4#5 \q_recursion_tail \q_recursion_stop
}
@@ -3083,6 +3127,7 @@
{ \use_i_delimit_by_q_recursion_stop:nw { {#2} } }
{ \@@_round_engineering:nnN { #1 - 1 } { #2#3 } }
}
+\cs_generate_variant:Nn \@@_round_engineering:nnN { V }
\cs_new:Npn \@@_round_fixed:nn #1#2 { {#1} {#2} }
\cs_new:Npn \@@_round_input:nn #1#2 { {#1} {#2} }
\cs_new:Npn \@@_round_scientific:nn #1#2
@@ -3092,7 +3137,7 @@
{ \str_if_eq_p:Vn \l_@@_round_mode_tl { figures } }
{ { 1 } { } }
{
- \@@_exponent_shift:nnf
+ \@@_exponent_shift:nne
{ 1 } {#1} { \@@_round_truncate_direct:n {#2} }
}
\@@_round_final_shift:Nw 1
@@ -3195,7 +3240,8 @@
%
% \begin{macro}[EXP]{\@@_round_figures:nnnnnnn, \@@_round_figures_aux:nnnnnnn}
% \begin{macro}[EXP]{\@@_round_figures_count:nnN}
-% \begin{macro}[EXP]{\@@_round_figures_count:nnnN}
+% \begin{macro}[EXP]
+% {\@@_round_figures_count:nnnN, \@@_round_figures_count:ennN}
% Rounding to figures only makes sense if the number is not $0$, so we start
% by filtering out that case. We then check that
% there is no uncertainty, and that the number of figures requested is
@@ -3245,7 +3291,7 @@
{
\int_compare:nNnTF {#1} > \l_@@_round_precision_int
{
- \@@_round:fnn
+ \@@_round:enn
{ \int_eval:n { #1 - \l_@@_round_precision_int } }
{#2} {#3}
}
@@ -3254,9 +3300,10 @@
{ \l_@@_round_precision_int - (#1) } {#2} {#3}
}
}
- \exp_args:Nf \@@_round_figures_count:nnnN
+ \@@_round_figures_count:ennN
{ \int_eval:n { #1 + 1 } } {#2} {#3}
}
+\cs_generate_variant:Nn \@@_round_figures_count:nnnN { e }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -3264,7 +3311,7 @@
%
% \begin{macro}[EXP]{\@@_round_places:nnnnnnn}
% \begin{macro}[EXP]{\@@_round_places_decimal:nn, \@@_round_places_integer:nn}
-% \begin{macro}[EXP]{\@@_round_places_finalise:n}
+% \begin{macro}[EXP]{\@@_round_places_finalise:n, \@@_round_places_finalise:e}
% \begin{macro}[EXP]{\@@_round_places_finalise:nnnnnnn}
% \begin{macro}[EXP]{\@@_round_places_finalise:nnnnn}
% The first step when rounding to a fixed number of places is to establish
@@ -3277,7 +3324,7 @@
{
\tl_if_blank:nTF {#5}
{
- \exp_args:Ne \@@_round_places_finalise:n
+ \@@_round_places_finalise:e
{
\exp_not:n { {#1} {#2} }
\int_compare:nNnTF \l_@@_round_precision_int > 0
@@ -3299,7 +3346,7 @@
{#1} {#2}
}
{
- \@@_round:fnn
+ \@@_round:enn
{
\int_eval:n
{ 0 \tl_count:n {#2} - \l_@@_round_precision_int }
@@ -3309,7 +3356,7 @@
}
\cs_new:Npn \@@_round_places_integer:nn #1#2
{
- \@@_round:fnn
+ \@@_round:enn
{
\int_eval:n
{ 0 \tl_count:n {#2} - \l_@@_round_precision_int }
@@ -3347,6 +3394,7 @@
}
{ \exp_not:n { {#1} {#2} {#3} {#4} {#5} {#6} {#7} } }
}
+\cs_generate_variant:Nn \@@_round_places_finalise:n { e }
\cs_new:Npn \@@_round_places_finalise:nnnnn #1#2#3#4#5
{
{
@@ -3364,17 +3412,28 @@
% \end{macro}
%
% \begin{macro}[EXP]{\@@_round_uncertainty:nnnnnnn}
-% \begin{macro}[EXP]{\@@_round_uncertainty:nnn}
-% \begin{macro}[EXP]{\@@_round_uncertainty:nnnn}
+% \begin{macro}[EXP]{\@@_round_uncertainty:nnn, \@@_round_uncertainty:nno}
+% \begin{macro}[EXP]
+% {\@@_round_uncertainty:nnnn, \@@_round_uncertainty:ennn}
% \begin{macro}[EXP]{\@@_round_uncertainty:nnnnnn}
% \begin{macro}[EXP]
% {
% \@@_round_uncertainty_auxi:nnnnn ,
% \@@_round_uncertainty_auxii:nnnnn
% }
-% \begin{macro}[EXP]{\@@_round_uncertainty_auxiii:nnnnnnn}
+% \begin{macro}[EXP]
+% {
+% \@@_round_uncertainty_auxiii:nnnnnnn ,
+% \@@_round_uncertainty_auxiii:eennnnn
+% }
% \begin{macro}[EXP]{\@@_round_uncertainty_zeros:nnnn}
-% \begin{macro}[EXP]{\@@_round_uncertainty_auxiv:nnnnnnN}
+% \begin{macro}[EXP]
+% {
+% \@@_round_uncertainty_auxiv:nnnnnnN ,
+% \@@_round_uncertainty_auxiv:nennnnN ,
+% \@@_round_uncertainty_auxiv:ennnnnN ,
+% \@@_round_uncertainty_auxiv:eennnnN
+% }
% \begin{macro}[EXP]{\@@_round_uncertainty_auxv:nnnN}
% \begin{macro}[EXP]{\@@_round_uncertainty_auxvi:nn}
% \begin{macro}[EXP]{\@@_round_uncertainty_auxvii:nnNnnn}
@@ -3406,7 +3465,7 @@
\str_if_eq:eeTF { \tl_head:n {#5} } { S }
{
\exp_not:n { {#1} {#2} }
- \exp_args:Nnno \@@_round_uncertainty:nnn
+ \@@_round_uncertainty:nno
{#3} {#4} { \use_ii:nn #5 }
{#6} {#7}
}
@@ -3420,13 +3479,14 @@
% \begin{macrocode}
\cs_new:Npn \@@_round_uncertainty:nnn #1#2#3
{
- \exp_args:Nf \@@_round_uncertainty:nnnn
+ \@@_round_uncertainty:ennn
{
\int_eval:n
{ \tl_count:n {#3} - \l_@@_round_precision_int }
}
{#1} {#2} {#3}
}
+\cs_generate_variant:Nn \@@_round_uncertainty:nnn { nno }
\cs_new:Npn \@@_round_uncertainty:nnnn #1#2#3#4
{
\use:e
@@ -3437,6 +3497,7 @@
{#2} {#3} {#1} {#4}
}
}
+\cs_generate_variant:Nn \@@_round_uncertainty:nnnn { e }
% \end{macrocode}
% The number of digits to remove from the main part and the detail of
% zero filling depends on whether we rounded up the uncertainty. So there
@@ -3455,7 +3516,7 @@
% \begin{macrocode}
\cs_new:Npn \@@_round_uncertainty_auxi:nnnnn #1#2#3#4#5
{
- \exp_args:Nf \@@_round_uncertainty_auxiv:nnnnnnN
+ \@@_round_uncertainty_auxiv:ennnnnN
{ \@@_round_uncertainty_zeros:nnnn {#1} {#3} {#4} {#5} }
{#4}
{#2} {#3} {#1} { }
@@ -3467,7 +3528,7 @@
% \begin{macrocode}
\cs_new:Npn \@@_round_uncertainty_auxii:nnnnn #1#2#3#4#5
{
- \exp_args:Nff \@@_round_uncertainty_auxiii:nnnnnnn
+ \@@_round_uncertainty_auxiii:eennnnn
{ \tl_count:n {#5} }
{ \tl_count:n {#3} }
{#1} {#2} {#3} {#4} {#5}
@@ -3479,26 +3540,21 @@
\bool_lazy_and:nnTF
{ \int_compare_p:nNn \l_@@_round_precision_int = 2 }
{ \int_compare_p:nNn {#1} = {#2} }
- {
- \exp_args:Nnf \@@_round_uncertainty_auxiv:nnnnnnN
- { 0 }
- }
- {
- \exp_args:Nnf \@@_round_uncertainty_auxiv:nnnnnnN
- { }
- }
+ { \@@_round_uncertainty_auxiv:nennnnN { 0 } }
+ { \@@_round_uncertainty_auxiv:nennnnN { } }
{ \int_eval:n { #6 + 1 } }
{#4} {#5} { 1 } { }
\@@_round_uncertainty_auxvii:nnNnnn
}
{
- \exp_args:Nff \@@_round_uncertainty_auxiv:nnnnnnN
+ \@@_round_uncertainty_auxiv:eennnnN
{ \@@_round_uncertainty_zeros:nnnn {#3} {#5} {#6} {#7} }
{ \int_eval:n { #6 + 1 } }
{#4} {#5} { 1 } {#3}
\@@_round_uncertainty_auxvii:nnNnnn
}
}
+\cs_generate_variant:Nn \@@_round_uncertainty_auxiii:nnnnnnn { ee }
\cs_new:Npn \@@_round_uncertainty_zeros:nnnn #1#2#3#4
{
\prg_replicate:nn
@@ -3530,6 +3586,7 @@
{#3} #7
\@@_round_end:nnn { { S } { #5#6 #1 } }
}
+\cs_generate_variant:Nn \@@_round_uncertainty_auxiv:nnnnnnN { ne , e , ee }
\cs_new:Npn \@@_round_uncertainty_auxv:nnnN #1#2#3#4
{
\int_compare:nNnT { \tl_count:n {#1} } > { \tl_count:n {#3} }
@@ -3668,27 +3725,30 @@
%
% \subsection{Number modification}
%
-% \begin{macro}[rEXP]{\siunitx_number_adjust_exponent:nn}
-% \begin{macro}[rEXP]{\siunitx_number_adjust_exponent:Nn}
-% \begin{macro}[rEXP]{\@@_adjust_exp:nnnnnnnn}
-% \begin{macro}[rEXP]{\@@_adjust_exp:nn}
-% \begin{macro}[rEXP]{\@@_adjust_exp:nNw}
+% \begin{macro}[EXP]
+% {\siunitx_number_adjust_exponent:nn, \siunitx_number_adjust_exponent:Vn}
+% \begin{macro}[EXP]{\siunitx_number_adjust_exponent:Nn}
+% \begin{macro}[EXP]{\@@_adjust_exp:nnnnnnnn}
+% \begin{macro}[EXP]{\@@_adjust_exp:nn, \@@_adjust_exp:en}
+% \begin{macro}[EXP]{\@@_adjust_exp:nNw}
% A simply case of breaking down and rebuilding the number.
% \begin{macrocode}
\cs_new:Npn \siunitx_number_adjust_exponent:nn #1#2
{ \@@_adjust_exp:nnnnnnnn #1 {#2} }
+\cs_generate_variant:Nn \siunitx_number_adjust_exponent:nn { V }
\cs_new:Npn \siunitx_number_adjust_exponent:Nn #1#2
{
\tl_if_empty:NF #1
- { \exp_args:NV \siunitx_number_adjust_exponent:nn #1 {#2} }
+ { \siunitx_number_adjust_exponent:Vn #1 {#2} }
}
\cs_new:Npn \@@_adjust_exp:nnnnnnnn #1#2#3#4#5#6#7#8
{
\exp_not:n { {#1} {#2} {#3} {#4} {#5} }
- \exp_args:Ne \@@_adjust_exp:nn { \fp_eval:n { #6#7 + #8 } } {#6}
+ \@@_adjust_exp:en { \fp_eval:n { #6#7 + #8 } } {#6}
}
\cs_new:Npn \@@_adjust_exp:nn #1#2
{ \@@_adjust_exp:nNw {#2} #1 \q_stop }
+\cs_generate_variant:Nn \@@_adjust_exp:nn { e }
\cs_new:Npn \@@_adjust_exp:nNw #1#2#3 \q_stop
{
\token_if_eq_meaning:NNTF #2 -
@@ -3851,87 +3911,88 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{macro}[rEXP]{\siunitx_number_output:N}
-% \begin{macro}[rEXP]{\siunitx_number_output:n}
-% \begin{macro}[rEXP]{\siunitx_number_output:NN}
-% \begin{macro}[rEXP]{\siunitx_number_output:nN}
-% \begin{macro}[rEXP]{\@@_output:Nn}
-% \begin{macro}[rEXP]{\@@_output:nn}
-% \begin{macro}[rEXP]{\@@_output:nnnnnnn}
-% \begin{macro}[rEXP]{\@@_output_bracket:nn}
-% \begin{macro}[rEXP]{\@@_output_bracket:w}
-% \begin{macro}[rEXP]{\@@_output_comparator:nn}
-% \begin{macro}[rEXP]{\@@_output_sign:nnn}
-% \begin{macro}[rEXP]{\@@_output_sign:nN}
-% \begin{macro}[rEXP]
+% \begin{macro}[EXP]{\siunitx_number_output:N, \siunitx_number_output:c}
+% \begin{macro}[EXP]{\siunitx_number_output:n}
+% \begin{macro}[EXP]{\siunitx_number_output:NN, \siunitx_number_output:cN}
+% \begin{macro}[EXP]{\siunitx_number_output:nN}
+% \begin{macro}[EXP]{\@@_output:Nn}
+% \begin{macro}[EXP]{\@@_output:nn}
+% \begin{macro}[EXP]{\@@_output:nnnnnnn}
+% \begin{macro}[EXP]{\@@_output_bracket:nn}
+% \begin{macro}[EXP]{\@@_output_bracket:w}
+% \begin{macro}[EXP]{\@@_output_comparator:nn}
+% \begin{macro}[EXP]{\@@_output_sign:nnn}
+% \begin{macro}[EXP]{\@@_output_sign:nN}
+% \begin{macro}[EXP]
% {\@@_output_sign_color:w, \@@_output_sign_brackets:w}
-% \begin{macro}[rEXP]{\@@_output_integer:nnn}
-% \begin{macro}[rEXP]{\@@_output_decimal:nn, \@@_output_decimal:fn}
-% \begin{macro}[rEXP]{\@@_output_digits:nn}
-% \begin{macro}[rEXP]{\@@_output_digit_separator:N}
-% \begin{macro}[rEXP]{\@@_output_integer_3_3:n}
-% \begin{macro}[rEXP]
+% \begin{macro}[EXP]{\@@_output_integer:nnn}
+% \begin{macro}[EXP]{\@@_output_decimal:nn, \@@_output_decimal:en}
+% \begin{macro}[EXP]{\@@_output_digits:nn}
+% \begin{macro}[EXP]{\@@_output_digit_separator:N}
+% \begin{macro}[EXP]{\@@_output_integer_3_3:n}
+% \begin{macro}[EXP]
% {
% \@@_output_integer_aux_0:n,
% \@@_output_integer_aux_1:n,
% \@@_output_integer_aux_2:n
% }
-% \begin{macro}[rEXP]{\@@_output_integer_first:nnNN}
-% \begin{macro}[rEXP]{\@@_output_integer_loop:NNNN}
-% \begin{macro}[rEXP]{\@@_output_integer_first:n}
-% \begin{macro}[rEXP]{\@@_output_integer_aux:n}
-% \begin{macro}[rEXP]{\@@_output_integer_loop:NnnN}
-% \begin{macro}[rEXP]{\@@_output_decimal_3_3:n}
-% \begin{macro}[rEXP]{\@@_output_decimal_loop:NNNN}
-% \begin{macro}[rEXP]{\@@_output_decimal_3_2:n}
-% \begin{macro}[rEXP]{\@@_output_decimal:NNNw}
-% \begin{macro}[rEXP]{\@@_output_decimal_loop:NN}
-% \begin{macro}[rEXP]{\@@_output_decimal_first:n}
-% \begin{macro}[rEXP]{\@@_output_decimal_loop:NnnN}
-% \begin{macro}[rEXP]{\@@_output_uncertainty:nnn}
-% \begin{macro}[rEXP]{\@@_output_uncertainty_unaligned:n}
-% \begin{macro}[rEXP]{\@@_output_uncert:nnnn}
-% \begin{macro}[rEXP]{\@@_output_uncert:nnnnn}
-% \begin{macro}[rEXP]{\@@_output_uncert_loop:nnN}
-% \begin{macro}[rEXP]{\@@_output_uncert_loop:nnNw}
-% \begin{macro}[rEXP]
+% \begin{macro}[EXP]{\@@_output_integer_first:nnNN}
+% \begin{macro}[EXP]{\@@_output_integer_loop:NNNN}
+% \begin{macro}[EXP]{\@@_output_integer_first:n}
+% \begin{macro}[EXP]{\@@_output_integer_aux:n, \@@_output_integer_aux:e}
+% \begin{macro}[EXP]{\@@_output_integer_loop:NnnN}
+% \begin{macro}[EXP]{\@@_output_decimal_3_3:n}
+% \begin{macro}[EXP]{\@@_output_decimal_loop:NNNN}
+% \begin{macro}[EXP]{\@@_output_decimal_3_2:n}
+% \begin{macro}[EXP]{\@@_output_decimal:NNNw}
+% \begin{macro}[EXP]{\@@_output_decimal_loop:NN}
+% \begin{macro}[EXP]{\@@_output_decimal_first:n}
+% \begin{macro}[EXP]{\@@_output_decimal_loop:NnnN}
+% \begin{macro}[EXP]{\@@_output_uncertainty:nnn}
+% \begin{macro}[EXP]{\@@_output_uncertainty_unaligned:n}
+% \begin{macro}[EXP]{\@@_output_uncert:nnnn}
+% \begin{macro}[EXP]{\@@_output_uncert:nnnnn, \@@_output_uncert:Vnnnn}
+% \begin{macro}[EXP]{\@@_output_uncert_loop:nnN}
+% \begin{macro}[EXP]{\@@_output_uncert_loop:nnNw}
+% \begin{macro}[EXP]
% {
% \@@_output_uncert_desc_bracket:n ,
% \@@_output_uncert_desc_bracket-separator:n ,
% \@@_output_uncert_desc_separator:n ,
% \@@_output_uncert_desc_subscript:n
% }
-% \begin{macro}[rEXP]{\@@_output_uncert_A_loop:nnn, \@@_output_uncert_S_loop:nnn}
-% \begin{macro}[rEXP]{\@@_output_uncert_S_loop:w}
-% \begin{macro}[rEXP]{\@@_output_uncert_A:nnnn, \@@_output_uncert_A_multi:nnnn}
-% \begin{macro}[rEXP]{\@@_output_uncert_A:nnnnn}
-% \begin{macro}[rEXP]
+% \begin{macro}[EXP]{\@@_output_uncert_A_loop:nnn, \@@_output_uncert_S_loop:nnn}
+% \begin{macro}[EXP]{\@@_output_uncert_S_loop:w}
+% \begin{macro}[EXP]{\@@_output_uncert_A:nnnn, \@@_output_uncert_A_multi:nnnn}
+% \begin{macro}[EXP]{\@@_output_uncert_A:nnnnn}
+% \begin{macro}[EXP]
% {
% \@@_output_uncert_S:nnnn ,
% \@@_output_uncert_S_sep:nnnn ,
% \@@_output_uncert_S_multi:nnnn
% }
-% \begin{macro}[rEXP]
+% \begin{macro}[EXP]
% {
% \@@_output_uncert_S_compact:nn ,
% \@@_output_uncert_S_compact-marker:nn ,
% \@@_output_uncert_S_full:nn
% }
-% \begin{macro}[rEXP]
+% \begin{macro}[EXP]
% {\@@_output_uncert_augment:nnnn}
-% \begin{macro}[rEXP]
-% {\@@_output_uncert_augment:nnn}
-% \begin{macro}[rEXP]
-% {\@@_output_uncert_augment:nnnw, \@@_output_uncert_augment:fnnw}
-% \begin{macro}[rEXP]{\@@_output_uncert_augment:nnw}
-% \begin{macro}[rEXP]
+% \begin{macro}[EXP]
+% {\@@_output_uncert_augment:nnn, \@@_output_uncert_augment:enn}
+% \begin{macro}[EXP]
+% {\@@_output_uncert_augment:nnnw, \@@_output_uncert_augment:ennw}
+% \begin{macro}[EXP]{\@@_output_uncert_augment:nnw}
+% \begin{macro}[EXP]
% {
% \@@_output_exponent:nnnnn ,
% \@@_output_exponent_auxi:nnnnn ,
-% \@@_output_exponent_auxii:nnnnn
+% \@@_output_exponent_auxii:nnnnn ,
+% \@@_output_exponent_auxiii:nnnnn
% }
-% \begin{macro}[rEXP]{\@@_output_exponent_auxiii:nn}
-% \begin{macro}[rEXP]{\@@_output_end:}
+% \begin{macro}[EXP]{\@@_output_exponent_auxiv:nn}
+% \begin{macro}[EXP]{\@@_output_end:}
% The approach to formatting a single number is to split into
% the constituent parts. All of the parts are assembled including
% inserting tabular alignment markers (which may be empty) for each
@@ -3939,10 +4000,12 @@
% \begin{macrocode}
\cs_new:Npn \siunitx_number_output:N #1
{ \@@_output:Nn #1 { } }
+\cs_generate_variant:Nn \siunitx_number_output:N { c }
\cs_new:Npn \siunitx_number_output:n #1
{ \@@_output:nn #1 { } }
\cs_new:Npn \siunitx_number_output:NN #1#2
{ \@@_output:Nn #1 {#2} }
+\cs_generate_variant:Nn \siunitx_number_output:NN { c }
\cs_new:Npn \siunitx_number_output:nN #1#2
{ \@@_output:nn #1 {#2} }
\cs_new:Npn \@@_output:Nn #1#2
@@ -3982,7 +4045,11 @@
{
\bool_lazy_or_p:nn
{ \l_@@_zero_exponent_bool }
- { ! \str_if_eq_p:nn {#2} { 0 } }
+ {
+ ! \bool_lazy_or_p:nn
+ { \tl_if_blank_p:n {#2} }
+ { \str_if_eq_p:nn {#2} { 0 } }
+ }
}
}
\@@_output_bracket:w
@@ -4118,7 +4185,7 @@
{ \@@_output_digits:nn { decimal } {#1} }
}
}
-\cs_generate_variant:Nn \@@_output_decimal:nn { f }
+\cs_generate_variant:Nn \@@_output_decimal:nn { e }
\cs_new:Npn \@@_output_digits:nn #1#2
{
\bool_if:cTF { l_@@_group_ #1 _ bool }
@@ -4192,13 +4259,14 @@
% \begin{macrocode}
\cs_new:Npn \@@_output_integer_first:n #1
{
- \exp_args:Ne \@@_output_integer_aux:n { \tl_reverse:n {#1} }
+ \@@_output_integer_aux:e { \tl_reverse:n {#1} }
}
\cs_new:Npn \@@_output_integer_aux:n #1
{
\@@_output_integer_loop:NnnN \l_@@_group_first_int { 0 } { }
#1 \q_recursion_tail \q_recursion_stop
}
+\cs_generate_variant:Nn \@@_output_integer_aux:n { e }
\cs_new:Npn \@@_output_integer_loop:NnnN #1#2#3#4
{
\quark_if_recursion_tail_stop_do:Nn #4 {#3}
@@ -4325,7 +4393,7 @@
% \begin{macrocode}
\cs_new:Npn \@@_output_uncert:nnnn #1#2#3#4
{
- \exp_args:NV \@@_output_uncert:nnnnn \l_@@_uncert_desc_clist
+ \@@_output_uncert:Vnnnn \l_@@_uncert_desc_clist
{#1} {#2} {#3} {#4}
}
\cs_new:Npn \@@_output_uncert:nnnnn #1#2#3#4#5
@@ -4333,6 +4401,7 @@
\@@_output_uncert_loop:nnN {#2} {#3}
#4 \q_recursion_tail #1 , \q_recursion_stop {#5}
}
+\cs_generate_variant:Nn \@@_output_uncert:nnnnn { V }
\cs_new:Npn \@@_output_uncert_loop:nnN #1#2#3
{
\quark_if_recursion_tail_stop:N #3
@@ -4473,7 +4542,7 @@
% \begin{macrocode}
\cs_new:Npn \@@_output_uncert_augment:nnnn #1#2#3#4
{
- \exp_args:Nf \@@_output_uncert_augment:nnn
+ \@@_output_uncert_augment:enn
{ \int_eval:n { \tl_count:n {#1} - \tl_count:n {#2} } }
{#3} {#4}
}
@@ -4481,7 +4550,7 @@
{
\int_compare:nNnTF {#1} > 0
{
- \@@_output_uncert_augment:fnnw
+ \@@_output_uncert_augment:ennw
{ \int_eval:n { #1 - 1 } }
{#3}
{ }
@@ -4489,7 +4558,7 @@
}
{
0
- \@@_output_decimal:fn
+ \@@_output_decimal:en
{
\prg_replicate:nn { \int_abs:n {#1} } { 0 }
#2
@@ -4497,6 +4566,7 @@
{#3}
}
}
+\cs_generate_variant:Nn \@@_output_uncert_augment:nnn { e }
\cs_new:Npn \@@_output_uncert_augment:nnnw #1#2#3#4
{
\quark_if_nil:NF #4
@@ -4504,14 +4574,14 @@
\int_compare:nNnTF {#1} = 0
{ \@@_output_uncert_augment:nnw {#3#4} {#2} }
{
- \@@_output_uncert_augment:fnnw
+ \@@_output_uncert_augment:ennw
{ \int_eval:n { #1 - 1 } }
{#2}
{#3#4}
}
}
}
-\cs_generate_variant:Nn \@@_output_uncert_augment:nnnw { f }
+\cs_generate_variant:Nn \@@_output_uncert_augment:nnnw { e }
\cs_new:Npn \@@_output_uncert_augment:nnw #1#2#3 \q_nil
{
\@@_output_digits:nn { integer } {#1}
@@ -4529,18 +4599,28 @@
\cs_new:Npn \@@_output_exponent:nnnnn #1#2#3#4#5
{
\exp_not:n {#5}
+ \str_if_empty:nTF {#2}
+ {
+ \bool_if:NTF \l_@@_zero_exponent_bool
+ { \@@_output_exponent_auxi:nnnnn {#1} { 0 } {#3} {#4} {#5} }
+ { \exp_not:n {#5} }
+ }
+ { \@@_output_exponent_auxi:nnnnn {#1} {#2} {#3} {#4} {#5} }
+ }
+\cs_new:Npn \@@_output_exponent_auxi:nnnnn #1#2#3#4#5
+ {
\bool_lazy_or:nnTF
{ \l_@@_zero_exponent_bool }
{ ! \str_if_eq_p:nn {#2} { 0 } }
{
\tl_if_empty:NTF \l_@@_output_exp_marker_tl
- { \@@_output_exponent_auxi:nnnnn }
{ \@@_output_exponent_auxii:nnnnn }
+ { \@@_output_exponent_auxiii:nnnnn }
{#1} {#2} {#3} {#4} {#5}
}
{ \exp_not:n {#5} }
}
-\cs_new:Npn \@@_output_exponent_auxi:nnnnn #1#2#3#4#5
+\cs_new:Npn \@@_output_exponent_auxii:nnnnn #1#2#3#4#5
{
\bool_lazy_or:nnT
{
@@ -4562,15 +4642,15 @@
\exp_not:n {#5}
\exp_not:V \l_@@_exponent_base_tl
^
- { \@@_output_exponent_auxiii:nnn { } {#1} {#2} }
+ { \@@_output_exponent_auxiv:nnn { } {#1} {#2} }
}
-\cs_new:Npn \@@_output_exponent_auxii:nnnnn #1#2#3#4#5
+\cs_new:Npn \@@_output_exponent_auxiii:nnnnn #1#2#3#4#5
{
\exp_not:n {#5}
\exp_not:V \l_@@_output_exp_marker_tl
- \@@_output_exponent_auxiii:nnn { \mathord } {#1} {#2}
+ \@@_output_exponent_auxiv:nnn { \mathord } {#1} {#2}
}
-\cs_new:Npn \@@_output_exponent_auxiii:nnn #1#2#3
+\cs_new:Npn \@@_output_exponent_auxiv:nnn #1#2#3
{
\tl_if_blank:nTF {#2}
{