summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/siunitx/siunitx-number.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-06-02 03:04:23 +0000
committerNorbert Preining <norbert@preining.info>2021-06-02 03:04:23 +0000
commit138d0a6cfd5f2187973fb6b83ad2fb0dcf5a8348 (patch)
treea95fba7d01d57bba550f5114c936ec76d57a49ac /macros/latex/contrib/siunitx/siunitx-number.dtx
parent0f69e2fd4a9928663f0cc64b8cac1f0d8baee9d6 (diff)
CTAN sync 202106020304
Diffstat (limited to 'macros/latex/contrib/siunitx/siunitx-number.dtx')
-rw-r--r--macros/latex/contrib/siunitx/siunitx-number.dtx139
1 files changed, 62 insertions, 77 deletions
diff --git a/macros/latex/contrib/siunitx/siunitx-number.dtx b/macros/latex/contrib/siunitx/siunitx-number.dtx
index 070b9c5e9d..b304a573c9 100644
--- a/macros/latex/contrib/siunitx/siunitx-number.dtx
+++ b/macros/latex/contrib/siunitx/siunitx-number.dtx
@@ -2708,7 +2708,8 @@
%
% \begin{macro}[EXP]{\@@_round_uncertainty:nnnnnnn}
% \begin{macro}[EXP]{\@@_round_uncertainty:nnn}
-% \begin{macro}[EXP]{\@@_round_uncertainty:nnnnn}
+% \begin{macro}[EXP]{\@@_round_uncertainty:nnnnn, \@@_round_uncertainty_aux:nnnnn}
+% \begin{macro}[EXP]{\@@_round_uncertainty_aux:nnnnnn}
% Rounding to an uncertainty can only happen where the result will have some
% uncertainty left: otherwise we simply drop the uncertainty entirely. Only
% |S|-type uncertainties can be used for rounding.
@@ -2740,28 +2741,54 @@
\exp_last_unbraced:Nf \@@_round_uncertainty:nnnnn
{
\@@_round:fnn
- { \tl_count:n {#3} - \l_@@_round_precision_int } { } {#3}
+ {
+ \int_eval:n
+ { \tl_count:n {#3} - \l_@@_round_precision_int }
+ }
+ { } {#3}
}
{#1} {#2} {#3}
}
\cs_new:Npn \@@_round_uncertainty:nnnnn #1#2#3#4#5
{
- \tl_if_blank:nTF {#1}
+ \exp_args:Nf \@@_round_uncertainty_aux:nnnnn
+ { \int_eval:n { \tl_count:n {#5} - \tl_count:n {#2} } }
+ {#1} {#2} {#3} {#4}
+ }
+% \end{macrocode}
+% The first argument here deals with the case where we've lost digits
+% in the uncertainty and it's purely located in the integer part.
+% \begin{macrocode}
+\cs_new:Npn \@@_round_uncertainty_aux:nnnnn #1#2#3#4#5
+ {
+ \exp_args:Nf \@@_round_uncertainty_aux:nnnnnn
{
- \@@_round:fnn
- { \tl_count:n {#5} - \tl_count:n {#2} } {#3} {#4}
- { { S } {#2} }
+ \tl_if_blank:nT {#5}
+ { \prg_replicate:nn {#1} { 0 } }
+ }
+ {#1} {#2} {#3} {#4} {#5}
+ }
+\cs_new:Npn \@@_round_uncertainty_aux:nnnnnn #1#2#3#4#5#6
+ {
+ \tl_if_blank:nTF {#3}
+ {
+ \@@_round:nnn
+ {#2}
+ {#5} {#6}
+ { { S } { #4 #1 } }
}
{
\@@_round:fnn
- { \tl_count:n {#5} - \tl_count:n {#2} + 1 } {#3} {#4}
- { { S } { #1 \@@_round_truncate_direct:n {#2} } }
+ { \int_eval:n { #2 + 1 } }
+ {#5} {#6}
+ { { S } { #3 \@@_round_truncate_direct:n {#4} #1 } }
}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\@@_zero_decimal:NN}
% \begin{macro}[EXP]{\@@_zero_decimal:nnnnnnn}
@@ -2966,17 +2993,14 @@
% \begin{macro}[rEXP]{\@@_output_decimal_loop:NNNN}
% \begin{macro}[rEXP]{\@@_output_integer_first:nnNN}
% \begin{macro}[rEXP]{\@@_output_integer_loop:NNNN}
-% \begin{macro}[rEXP]{\@@_output_uncertainty:nnnn}
+% \begin{macro}[rEXP]{\@@_output_uncertainty:nnn}
% \begin{macro}[rEXP]{\@@_output_uncertainty_unaligned:n}
-% \begin{macro}[rEXP]{\@@_output_uncert_S:nnnnw}
-% \begin{macro}[rEXP]{\@@_output_uncert_S_auxi:nn}
-% \begin{macro}[rEXP]{\@@_output_uncert_S_auxii:nnN}
-% \begin{macro}[rEXP]{\@@_output_uncert_S_auxiii:nnn}
+% \begin{macro}[rEXP]{\@@_output_uncert_S:nnnw}
% \begin{macro}[rEXP]
-% {\@@_output_uncert_S_auxiv:nnn, \@@_output_uncert_S_auxiv:fnn}
+% {\@@_output_uncert_S_aux:nnn, \@@_output_uncert_S_aux:fnn}
% \begin{macro}[rEXP]
-% {\@@_output_uncert_S_auxv:nnnw, \@@_output_uncert_S_auxv:fnnw}
-% \begin{macro}[rEXP]{\@@_output_uncert_S_auxvi:nnw}
+% {\@@_output_uncert_S:nnnw, \@@_output_uncert_S:fnw}
+% \begin{macro}[rEXP]{\@@_output_uncert_S:nnw}
% \begin{macro}[rEXP]
% {
% \@@_output_uncert_S_compact:nn ,
@@ -3022,7 +3046,7 @@
\@@_output_sign:nnn {#1} {#2} {#8}
\@@_output_integer:nnn {#3} {#4} {#7}
\@@_output_decimal:nn {#4} {#8}
- \@@_output_uncertainty:nnnn {#5} {#3} {#4} {#8}
+ \@@_output_uncertainty:nnn {#5} {#4} {#8}
\@@_output_exponent:nnnn {#6} {#7} { #3 . #4 } {#8}
\@@_output_end:
}
@@ -3232,77 +3256,41 @@
% digit tokens need to be removed from the start of the uncertainty and
% the split result sent to the appropriate auxiliaries.
% \begin{macrocode}
-\cs_new:Npn \@@_output_uncertainty:nnnn #1#2#3#4
+\cs_new:Npn \@@_output_uncertainty:nnn #1#2#3
{
\tl_if_blank:nTF {#1}
- { \@@_output_uncertainty_unaligned:n {#4} }
+ { \@@_output_uncertainty_unaligned:n {#3} }
{
- \use:c { @@_output_uncert_ \tl_head:n {#1} :nnnnw }
- {#2} {#3} {#4} #1
+ \use:c { @@_output_uncert_ \tl_head:n {#1} :nnnw }
+ {#2} {#3} #1
}
}
\cs_new:Npn \@@_output_uncertainty_unaligned:n #1
{ \exp_not:n { #1 #1 #1 #1 } }
-% \end{macrocode}
-% There is a bit more to do here if the uncertainty is purely in the integer
-% part and printed separately. We need to pad it by the number of
-% non-significant figures, then pass on to allow digit separation.
-% \begin{macrocode}
-\cs_new:Npn \@@_output_uncert_S:nnnnw #1#2#3#4#5
+\cs_new:Npn \@@_output_uncert_S:nnnw #1#2#3#4
{
\str_if_eq:VnTF \l_@@_uncert_mode_tl { separate }
{
- \exp_not:n {#3}
+ \exp_not:n {#2}
\@@_output_sign:N \pm
- \exp_not:n {#3}
- \tl_if_blank:nTF {#2}
- { \@@_output_uncert_S_auxi:nnn {#1} {#5} {#3} }
- {
- \@@_output_uncert_S_auxiv:fnn
- { \int_eval:n { \tl_count:n {#5} - \tl_count:n {#2} } }
- {#5} {#3}
- }
+ \exp_not:n {#2}
+ \@@_output_uncert_S_aux:nnn
+ { \int_eval:n { \tl_count:n {#4} - \tl_count:n {#1} } }
+ {#4} {#2}
}
{
\exp_not:V \l_@@_uncert_separator_tl
\exp_not:V \l_@@_output_uncert_open_tl
- \use:c { @@_output_uncert_S_ \l_@@_uncert_mode_tl :nn } {#2} {#5}
+ \use:c { @@_output_uncert_S_ \l_@@_uncert_mode_tl :nn } {#1} {#4}
\exp_not:V \l_@@_output_uncert_close_tl
- \@@_output_uncertainty_unaligned:n {#3}
- }
- }
-\cs_new:Npn \@@_output_uncert_S_auxi:nnn #1#2#3
- {
- \@@_output_uncert_S_auxii:nnN { 0 } {#2} #1
- \q_recursion_tail \q_recursion_stop {#3}
- }
-\cs_new:Npn \@@_output_uncert_S_auxii:nnN #1#2#3
- {
- \quark_if_recursion_tail_stop_do:Nn #3
- {
- \exp_args:Nf \@@_output_uncert_S_auxiii:nnn
- { \prg_replicate:nn {#1} { 0 } } {#2}
- }
- \str_if_eq:nnTF {#3} { 0 }
- {
- \exp_args:Nf \@@_output_uncert_S_auxii:nnN
- { \int_eval:n { #1 + 1 } } {#2}
+ \@@_output_uncertainty_unaligned:n {#2}
}
- { \@@_output_uncert_S_auxii:nnN { 0 } {#2} }
}
-\cs_new:Npn \@@_output_uncert_S_auxiii:nnn #1#2#3
- {
- \@@_output_uncert_S_auxiv:fnn
- { \int_eval:n { \tl_count:n {#2#1} } } {#2#1} {#3}
- }
-% \end{macrocode}
-% All separated uncertainties bring us to here.
-% \begin{macrocode}
-\cs_new:Npn \@@_output_uncert_S_auxiv:nnn #1#2#3
+\cs_new:Npn \@@_output_uncert_S_aux:nnn #1#2#3
{
\int_compare:nNnTF {#1} > 0
{
- \@@_output_uncert_S_auxv:fnnw
+ \@@_output_uncert_S_aux:fnnw
{ \int_eval:n { #1 - 1 } }
{#3}
{ }
@@ -3318,23 +3306,23 @@
{#3}
}
}
-\cs_generate_variant:Nn \@@_output_uncert_S_auxiv:nnn { f }
-\cs_new:Npn \@@_output_uncert_S_auxv:nnnw #1#2#3#4
+\cs_generate_variant:Nn \@@_output_uncert_S_aux:nnn { f }
+\cs_new:Npn \@@_output_uncert_S_aux:nnnw #1#2#3#4
{
\quark_if_nil:NF #4
{
\int_compare:nNnTF {#1} = 0
- { \@@_output_uncert_S_auxvi:nnw {#3#4} {#2} }
+ { \@@_output_uncert_S_aux:nnw {#3#4} {#2} }
{
- \@@_output_uncert_S_auxv:fnnw
+ \@@_output_uncert_S_aux:fnnw
{ \int_eval:n { #1 - 1 } }
{#2}
{#3#4}
}
}
}
-\cs_generate_variant:Nn \@@_output_uncert_S_auxv:nnnw { f }
-\cs_new:Npn \@@_output_uncert_S_auxvi:nnw #1#2#3 \q_nil
+\cs_generate_variant:Nn \@@_output_uncert_S_aux:nnnw { f }
+\cs_new:Npn \@@_output_uncert_S_aux:nnw #1#2#3 \q_nil
{
\@@_output_digits:nn { integer } {#1}
\@@_output_decimal:nn {#3} {#2}
@@ -3356,7 +3344,7 @@
}
\cs_new:Npn \@@_output_uncert_S_full:nn #1#2
{
- \@@_output_uncert_S_auxiv:fnn
+ \@@_output_uncert_S_aux:fnn
{ \int_eval:n { \tl_count:n {#2} - \tl_count:n {#1} } }
{#2} { }
}
@@ -3455,9 +3443,6 @@
% \end{macro}
% \end{macro}
% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
%
% \subsection{Miscellaneous tools}
%