summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/siunitx/siunitx-number.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/siunitx/siunitx-number.dtx')
-rw-r--r--macros/latex/contrib/siunitx/siunitx-number.dtx33
1 files changed, 20 insertions, 13 deletions
diff --git a/macros/latex/contrib/siunitx/siunitx-number.dtx b/macros/latex/contrib/siunitx/siunitx-number.dtx
index 61ca7af103..38db10d71b 100644
--- a/macros/latex/contrib/siunitx/siunitx-number.dtx
+++ b/macros/latex/contrib/siunitx/siunitx-number.dtx
@@ -1449,12 +1449,9 @@
% \begin{macro}{\@@_parse_uncert:NN}
% \begin{macro}{\@@_parse_uncert:NNNN}
% \begin{macro}{\@@_parse_uncert_auxi:NN, \@@_parse_uncert_auxii:NN}
-% \begin{macro}
-% {
-% \@@_parse_uncert_auxii:N ,
-% \@@_parse_uncert_marker:N ,
-% \@@_parse_uncert_after:N
-% }
+% \begin{macro} {\@@_parse_uncert_auxii:N, \@@_parse_uncert_marker:N}
+% \begin{macro}{\@@_parse_uncert_extend:nnnN}
+% \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,
% so we filter that out explicitly. After that, we check for digits,
@@ -1544,7 +1541,8 @@
% Handling a decimal marker in the uncertainty is a bit tricky: we need to make
% sure it's valid. First, we need to be sure that the integer part of the captured
% uncertainty is not too long. Then we need to check that the decimal part is
-% not too long. Both of these require data from the collected partial number,
+% not too long, and extend the decimal if it is.
+% Both of these require data from the collected partial number,
% so we extract that first. Checking the decimal part needs the length of the
% not-yet-collected uncertainty. Handily, we know that it should be a set of
% digits then a closing marker. So we can use that as a length: if it's
@@ -1578,9 +1576,15 @@
}
\@@_parse_uncert_auxii:NN
}
- { \@@_parse_loop_break:wN }
+ { \exp_after:wN \@@_parse_uncert_extend:nnnN #2 #2 }
#3 \q_recursion_tail \q_recursion_stop
}
+\cs_new_protected:Npn \@@_parse_uncert_extend:nnnN #1#2#3#4
+ {
+ \tl_set:Nn #4 { {#1} {#2} { #3 0 } }
+ \@@_parse_uncert:NNNN #4 \c_true_bool
+ \@@_parse_uncert_auxii:NN
+ }
% \end{macrocode}
% No further tokens are allowed after an uncertainty in parenthesis.
% \begin{macrocode}
@@ -1594,6 +1598,8 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
+% \end{macro}
%
% \subsection{Processing numbers}
%
@@ -2298,7 +2304,7 @@
\bool_lazy_all_p:n
{
{ \l_@@_round_half_even_bool }
- { \int_if_odd_p:n {#3} }
+ { ! \int_if_odd_p:n {#3} }
{ \@@_round_if_half_p:n {#1} }
}
}
@@ -2316,7 +2322,7 @@
\bool_lazy_all_p:n
{
{ \l_@@_round_half_even_bool }
- { \int_if_odd_p:n {#3} }
+ { ! \int_if_odd_p:n {#3} }
{ \@@_round_if_half_p:n {#1} }
}
}
@@ -2762,7 +2768,7 @@
}
\cs_new:Npn \@@_round_uncertainty:nnnnn #1#2#3#4#5
{
- \exp_args:Nf \@@_round_uncertainty_aux:nnnnn
+ \exp_args:Nff \@@_round_uncertainty_aux:nnnnn
{ \int_eval:n { \tl_count:n {#5} - \tl_count:n {#2} } }
{#1} {#2} {#3} {#4}
}
@@ -2774,8 +2780,9 @@
{
\exp_args:Nf \@@_round_uncertainty_aux:nnnnnn
{
- \tl_if_blank:nT {#5}
- { \prg_replicate:nn {#1} { 0 } }
+ \prg_replicate:nn
+ { \int_max:nn { #1 - \tl_count:n {#5} } { 0 } }
+ { 0 }
}
{#1} {#2} {#3} {#4} {#5}
}