[latex3-commits] [l3svn] r6892 - Infinity is actually even (fixes #272)
noreply at latex-project.org
noreply at latex-project.org
Sat Feb 11 20:05:17 CET 2017
Author: bruno
Date: 2017-02-11 20:05:17 +0100 (Sat, 11 Feb 2017)
New Revision: 6892
Modified:
trunk/l3kernel/l3fp-expo.dtx
trunk/l3kernel/l3fp.dtx
trunk/l3kernel/testfiles/m3fp-expo001.tlg
Log:
Infinity is actually even (fixes #272)
I finally understood why the standard defines (-1)^inf = (-1)^-inf = 1:
all large floating point numbers are even integers. It is now
implemented correctly in l3fp.
Modified: trunk/l3kernel/l3fp-expo.dtx
===================================================================
--- trunk/l3kernel/l3fp-expo.dtx 2017-02-11 18:37:26 UTC (rev 6891)
+++ trunk/l3kernel/l3fp-expo.dtx 2017-02-11 19:05:17 UTC (rev 6892)
@@ -863,17 +863,17 @@
% Raising a number $a$ to a power $b$ leads to many distinct situations.
% \begin{center}\def\abs#1{\lvert #1\rvert}
% \begin{tabular}{>{$}c<{$}|*8{>{$}l<{$}}}
-% a^b &-\infty &(-\infty,-0) &-p/5^k &\pm 0 &+p/5^k &(0,\infty) &+\infty &\nan \\ \hline
+% a^b &-\infty &(-\infty,-0) &-p/5^k &\pm 0 &+p/5^k &(0,\infty) &+\infty &\nan \\ \hline
% +\infty &+0 &\multicolumn{2}{c}{$+0$} &+1 &\multicolumn{2}{c}{$+\infty$} &+\infty &\nan \\
% (1,\infty) &+0 &\multicolumn{2}{c}{$+\abs{a}^{b}$} &+1 &\multicolumn{2}{c}{$+\abs{a}^{b}$} &+\infty &\nan \\
% +1 &+1 &\multicolumn{2}{c}{$+1$} &+1 &\multicolumn{2}{c}{$+1$} &+1 &+1 \\
% (0,1) &+\infty &\multicolumn{2}{c}{$+\abs{a}^{b}$} &+1 &\multicolumn{2}{c}{$+\abs{a}^{b}$} &+0 &\nan \\
% +0 &+\infty &\multicolumn{2}{c}{$+\infty$} &+1 &\multicolumn{2}{c}{$+0$} &+0 &\nan \\
-% -0 &\nan &\nan &(-1)^p\infty &+1 &(-1)^p 0 &+0 &+0 &\nan \\
-% (-1,0) &\nan &\nan &(-1)^p\abs{a}^{b} &+1 &(-1)^p\abs{a}^{b} &\nan &+0 &\nan \\
-% -1 &\nan &\nan &(-1)^p &+1 &(-1)^p &\nan &\nan &\nan \\
-% (-\infty,-1) &+0 &\nan &(-1)^p\abs{a}^{b} &+1 &(-1)^p\abs{a}^{b} &\nan &\nan &\nan \\
-% -\infty &+0 &+0 &(-1)^p 0 &+1 &(-1)^p\infty &\nan &\nan &\nan \\
+% -0 &+\infty &\nan &(-1)^p\infty &+1 &(-1)^p 0 &+0 &+0 &\nan \\
+% (-1,0) &+\infty &\nan &(-1)^p\abs{a}^{b} &+1 &(-1)^p\abs{a}^{b} &\nan &+0 &\nan \\
+% -1 &+1 &\nan &(-1)^p &+1 &(-1)^p &\nan &+1 &\nan \\
+% (-\infty,-1) &+0 &\nan &(-1)^p\abs{a}^{b} &+1 &(-1)^p\abs{a}^{b} &\nan &+\infty &\nan \\
+% -\infty &+0 &+0 &(-1)^p 0 &+1 &(-1)^p\infty &\nan &+\infty &\nan \\
% \nan &\nan &\nan &\nan &+1 &\nan &\nan &\nan &\nan \\
% \end{tabular}
% \end{center}
@@ -1190,8 +1190,9 @@
% \enquote{parity}. It should be used after \cs{if_case:w} or in an
% integer expression. It gives $-1$ if the number is an even integer
% divided by some power of~$5$, $0$~if the number is an odd integer
-% divided by some power of~$5$, and $1$~otherwise. Zeros are even,
-% $\pm\infty$ and \texttt{nan} are non-integers. The sign of normal
+% divided by some power of~$5$, and $1$~otherwise. Zeros and
+% $\pm\infty$ are even (because very large finite floating points are
+% even), while \texttt{nan} is a non-integer. The sign of normal
% numbers is irrelevant to parity. The idea is to repeatedly multiply
% the number by~$5$ (by halving the mantissa and shifting the
% exponent) until the mantissa is odd (this can only happen at most
@@ -1205,6 +1206,7 @@
\if_case:w #1 \exp_stop_f:
-\c_one
\or: \@@_pow_neg_case_aux:nnnnn #3
+ \or: -\c_one
\else: \c_one
\fi:
}
Modified: trunk/l3kernel/l3fp.dtx
===================================================================
--- trunk/l3kernel/l3fp.dtx 2017-02-11 18:37:26 UTC (rev 6891)
+++ trunk/l3kernel/l3fp.dtx 2017-02-11 19:05:17 UTC (rev 6892)
@@ -932,11 +932,13 @@
% \end{syntax}
% Raises \meta{operand_1} to the power \meta{operand_2}. This
% operation is right associative, hence \texttt{2 ** 2 ** 3} equals
-% $2^{2^{3}} = 256$. The \enquote{invalid operation} exception occurs
-% if \meta{operand_1} is negative or $-0$, and \meta{operand_2} is not
-% of the form $p/q$ with $p$ integer and $q$ odd,
-% unless the result is zero (in that case, the sign is
-% chosen arbitrarily to be $+0$). \enquote{Division by zero} occurs
+% $2^{2^{3}} = 256$. If \meta{operand_1} is negative or $-0$ then:
+% the result's sign is $+$ if the \meta{operand_2} is infinite and
+% $(-1)^p$ if the \meta{operand_2} is $p/q$ with $p$ integer and $q$
+% odd; the result is $+0$ if
+% |abs(|\meta{operand_1}|)^|\meta{operand_2} evaluates to zero; in
+% other cases the \enquote{invalid operation} exception occurs because
+% the sign cannot be determined. \enquote{Division by zero} occurs
% when raising $\pm 0$ to a finite strictly negative power.
% \enquote{Underflow} and \enquote{overflow} occur when appropriate.
% \end{function}
Modified: trunk/l3kernel/testfiles/m3fp-expo001.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3fp-expo001.tlg 2017-02-11 18:37:26 UTC (rev 6891)
+++ trunk/l3kernel/testfiles/m3fp-expo001.tlg 2017-02-11 19:05:17 UTC (rev 6892)
@@ -115,16 +115,7 @@
'(inf)^(-0.00128)' = 0
'(inf)^(1.3)' = inf
'(-inf)^(nan)' = nan
-! Undefined control sequence.
-<argument> \LaTeX3 error:
- Invalid operation (-inf)^(inf)
-l. ... }
-The control sequence at the end of the top line
-of your error message was never \def'ed. If you have
-misspelled it (e.g., `\hobx'), type `I' and the correct
-spelling (e.g., `I\hbox'). Otherwise just continue,
-and I'll forget about whatever was undefined.
-'(-inf)^(inf)' = nan
+'(-inf)^(inf)' = inf
'(-inf)^(-inf)' = 0
'(-inf)^(1)' = -inf
'(-inf)^(-1)' = -0
@@ -153,26 +144,8 @@
'(1)^(-0.00128)' = 1
'(1)^(1.3)' = 1
'(-1)^(nan)' = nan
-! Undefined control sequence.
-<argument> \LaTeX3 error:
- Invalid operation (-1)^(inf)
-l. ... }
-The control sequence at the end of the top line
-of your error message was never \def'ed. If you have
-misspelled it (e.g., `\hobx'), type `I' and the correct
-spelling (e.g., `I\hbox'). Otherwise just continue,
-and I'll forget about whatever was undefined.
-'(-1)^(inf)' = nan
-! Undefined control sequence.
-<argument> \LaTeX3 error:
- Invalid operation (-1)^(-inf)
-l. ... }
-The control sequence at the end of the top line
-of your error message was never \def'ed. If you have
-misspelled it (e.g., `\hobx'), type `I' and the correct
-spelling (e.g., `I\hbox'). Otherwise just continue,
-and I'll forget about whatever was undefined.
-'(-1)^(-inf)' = nan
+'(-1)^(inf)' = 1
+'(-1)^(-inf)' = 1
'(-1)^(1)' = -1
'(-1)^(-1)' = -1
'(-1)^(0)' = 1
@@ -219,16 +192,7 @@
'(0)^(1.3)' = 0
'(-0)^(nan)' = nan
'(-0)^(inf)' = 0
-! Undefined control sequence.
-<argument> \LaTeX3 error:
- Invalid operation (-0)^(-inf)
-l. ... }
-The control sequence at the end of the top line
-of your error message was never \def'ed. If you have
-misspelled it (e.g., `\hobx'), type `I' and the correct
-spelling (e.g., `I\hbox'). Otherwise just continue,
-and I'll forget about whatever was undefined.
-'(-0)^(-inf)' = nan
+'(-0)^(-inf)' = inf
'(-0)^(1)' = -0
! Undefined control sequence.
<argument> \LaTeX3 error:
More information about the latex3-commits
mailing list