summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-05-05 22:01:18 +0000
committerKarl Berry <karl@freefriends.org>2014-05-05 22:01:18 +0000
commitd78a5a4de1e73a2151e8ed2635a199d928ccb559 (patch)
treeca490a3efa7d3614793427f850ec1aeb6bf971f1 /Master/texmf-dist/source/latex/l3kernel/l3int.dtx
parentb41cac6cebc8095cf8eaf7e84f8a2d5f63b7be38 (diff)
latex3 (5may14)
git-svn-id: svn://tug.org/texlive/trunk@33859 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3int.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3int.dtx162
1 files changed, 121 insertions, 41 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
index 17b33143769..2fa99d37bc9 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-%% File: l3int.dtx Copyright (C) 1990-2013 The LaTeX3 Project
+%% File: l3int.dtx Copyright (C) 1990-2014 The LaTeX3 Project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -33,13 +33,14 @@
%%
%% -----------------------------------------------------------------------
%
+%<*driver>
+\documentclass[full]{l3doc}
+%</driver>
%<*driver|package>
-\RequirePackage{l3bootstrap}
-\GetIdInfo$Id: l3int.dtx 4583 2013-08-02 19:14:35Z joseph $
+\GetIdInfo$Id: l3int.dtx 4728 2014-05-04 13:25:37Z joseph $
{L3 Integers}
%</driver|package>
%<*driver>
-\documentclass[full]{l3doc}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
@@ -605,24 +606,26 @@
% \end{verbatim}
% \end{function}
%
-% \begin{function}[updated = 2011-09-17, EXP]{\int_to_binary:n}
+% \begin{function}[added = 2014-02-11, EXP]{\int_to_bin:n}
% \begin{syntax}
-% \cs{int_to_binary:n} \Arg{integer expression}
+% \cs{int_to_bin:n} \Arg{integer expression}
% \end{syntax}
% Calculates the value of the \meta{integer expression} and places
% the binary representation of the result in the input stream.
% \end{function}
%
-% \begin{function}[updated = 2011-09-17, EXP]{\int_to_hexadecimal:n}
+% \begin{function}[added = 2014-02-11, EXP]{\int_to_hex:n, \int_to_Hex:n}
% \begin{syntax}
-% \cs{int_to_hexadecimal:n} \Arg{integer expression}
+% \cs{int_to_hex:n} \Arg{integer expression}
% \end{syntax}
% Calculates the value of the \meta{integer expression} and places
% the hexadecimal (base~$16$) representation of the result in the
-% input stream. Upper case letters are used for digits beyond $9$.
+% input stream. Letters are used for digits beyond~$9$: lower
+% case letters for \cs{int_to_hex:n} and upper case ones for
+% \cs{int_to_Hex:n}.
% \end{function}
%
-% \begin{function}[updated = 2011-09-17, EXP]{\int_to_octal:n}
+% \begin{function}[added = 2014-02-11, EXP]{\int_to_oct:n}
% \begin{syntax}
% \cs{int_to_octal:n} \Arg{integer expression}
% \end{syntax}
@@ -631,18 +634,21 @@
% stream.
% \end{function}
%
-% \begin{function}[updated = 2011-09-17, EXP]{\int_to_base:nn}
+% \begin{function}[updated = 2014-02-11, EXP]
+% {\int_to_base:nn, \int_to_Base:nn}
% \begin{syntax}
% \cs{int_to_base:nn} \Arg{integer expression} \Arg{base}
% \end{syntax}
% Calculates the value of the \meta{integer expression} and
% converts it into the appropriate representation in the \meta{base};
% the later may be given as an integer expression. For bases greater
-% than $10$ the higher \enquote{digits} are represented by the upper case
-% letters from the English alphabet.
+% than $10$ the higher \enquote{digits} are represented by
+% letters from the English alphabet: lower
+% case letters for \cs{int_to_base:n} and upper case ones for
+% \cs{int_to_Base:n}.
% The maximum \meta{base} value is $36$.
% \begin{texnote}
-% This is a generic version of \cs{int_to_binary:n}, \emph{etc.}
+% This is a generic version of \cs{int_to_bin:n}, \emph{etc.}
% \end{texnote}
% \end{function}
%
@@ -670,17 +676,17 @@
% \cs{int_to_alph:n}.
% \end{function}
%
-% \begin{function}[EXP]{\int_from_binary:n}
+% \begin{function}[added = 2014-02-11, EXP]{\int_from_bin:n}
% \begin{syntax}
-% \cs{int_from_binary:n} \Arg{binary number}
+% \cs{int_from_bin:n} \Arg{binary number}
% \end{syntax}
% Converts the \meta{binary number} into the integer (base~$10$)
% representation and leaves this in the input stream.
% \end{function}
%
-% \begin{function}[EXP]{\int_from_hexadecimal:n}
+% \begin{function}[added = 2014-02-11, EXP]{\int_from_hex:n}
% \begin{syntax}
-% \cs{int_from_binary:n} \Arg{hexadecimal number}
+% \cs{int_from_hex:n} \Arg{hexadecimal number}
% \end{syntax}
% Converts the \meta{hexadecimal number} into the integer
% (base~$10$) representation and leaves this in the input stream.
@@ -688,9 +694,9 @@
% \meta{hexadecimal number} by upper or lower case letters.
% \end{function}
%
-% \begin{function}[EXP]{\int_from_octal:n}
+% \begin{function}[added = 2014-02-11, EXP]{\int_from_oct:n}
% \begin{syntax}
-% \cs{int_from_octal:n} \Arg{octal number}
+% \cs{int_from_oct:n} \Arg{octal number}
% \end{syntax}
% Converts the \meta{octal number} into the integer (base~$10$)
% representation and leaves this in the input stream.
@@ -914,14 +920,6 @@
%
% \TestFiles{m3int001,m3int002,m3int03}
%
-% \begin{macrocode}
-%<*package>
-\ProvidesExplPackage
- {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
-\__expl_package_check:
-%</package>
-% \end{macrocode}
-%
% \begin{macro}{\@@_to_roman:w}
% \begin{macro}{\if_int_compare:w}
% Done in \pkg{l3basics}.
@@ -1087,13 +1085,16 @@
% \begin{macro}{\int_new:N, \int_new:c}
% \UnitTested
% Two ways to do this: one for the format and one for the \LaTeXe{}
-% package.
+% package. In plain \TeX{}, \cs{newcount} (and other allocators) are
+% \cs{outer}: to allow the code here to work in \enquote{generic} mode
+% this is therefore accessed by name. (The same applies to \cs{newbox},
+% \cs{newdimen} and so on.)
% \begin{macrocode}
%<*package>
\cs_new_protected:Npn \int_new:N #1
{
\__chk_if_free_cs:N #1
- \newcount #1
+ \cs:w newcount \cs_end: #1
}
%</package>
\cs_generate_variant:Nn \int_new:N { c }
@@ -1830,9 +1831,9 @@
%
% \begin{macro}{\int_to_base:nn}
% \UnitTested
-% \begin{macro}[aux]{\@@_to_base:nn,
-% \@@_to_base:nnN,\@@_to_base:nnnN}
-% \begin{macro}[aux]{\@@_to_letter:n}
+% \begin{macro}[aux]{\@@_to_base:nn, \@@_to_Base:nn,
+% \@@_to_base:nnN,\@@_to_Base:nnN,\@@_to_base:nnnN,\@@_to_Base:nnnN}
+% \begin{macro}[aux]{\@@_to_letter:n, \@@_to_Letter:n}
% \UnitTested
% Converting from base ten (|#1|) to a second base (|#2|) starts with
% computing |#1|: if it is a complicated calculation, we shouldn't
@@ -1842,12 +1843,20 @@
% \begin{macrocode}
\cs_new:Npn \int_to_base:nn #1
{ \exp_args:Nf \@@_to_base:nn { \int_eval:n {#1} } }
+\cs_new:Npn \int_to_Base:nn #1
+ { \exp_args:Nf \@@_to_Base:nn { \int_eval:n {#1} } }
\cs_new:Npn \@@_to_base:nn #1#2
{
\int_compare:nNnTF {#1} < \c_zero
{ \exp_args:No \@@_to_base:nnN { \use_none:n #1 } {#2} - }
{ \@@_to_base:nnN {#1} {#2} \c_empty_tl }
}
+\cs_new:Npn \@@_to_Base:nn #1#2
+ {
+ \int_compare:nNnTF {#1} < \c_zero
+ { \exp_args:No \@@_to_Base:nnN { \use_none:n #1 } {#2} - }
+ { \@@_to_Base:nnN {#1} {#2} \c_empty_tl }
+ }
% \end{macrocode}
% Here, the idea is to provide a recursive system to deal with the
% input. The output is built up after the end of the function.
@@ -1879,6 +1888,26 @@
#4
#1
}
+\cs_new:Npn \@@_to_Base:nnN #1#2#3
+ {
+ \int_compare:nNnTF {#1} < {#2}
+ { \exp_last_unbraced:Nf #3 { \@@_to_Letter:n {#1} } }
+ {
+ \exp_args:Nf \@@_to_Base:nnnN
+ { \@@_to_Letter:n { \int_mod:nn {#1} {#2} } }
+ {#1}
+ {#2}
+ #3
+ }
+ }
+\cs_new:Npn \@@_to_Base:nnnN #1#2#3#4
+ {
+ \exp_args:Nf \@@_to_Base:nnN
+ { \int_div_truncate:nn {#2} {#3} }
+ {#3}
+ #4
+ #1
+ }
% \end{macrocode}
% Convert to a letter only if necessary, otherwise simply return the
% value unchanged. It would be cleaner to use \cs{int_case:nn},
@@ -1893,6 +1922,39 @@
{
\exp_after:wN \exp_after:wN
\if_case:w \@@_eval:w #1 - \c_ten \@@_eval_end:
+ a
+ \or: b
+ \or: c
+ \or: d
+ \or: e
+ \or: f
+ \or: g
+ \or: h
+ \or: i
+ \or: j
+ \or: k
+ \or: l
+ \or: m
+ \or: n
+ \or: o
+ \or: p
+ \or: q
+ \or: r
+ \or: s
+ \or: t
+ \or: u
+ \or: v
+ \or: w
+ \or: x
+ \or: y
+ \or: z
+ \else: \@@_value:w \@@_eval:w #1 \exp_after:wN \@@_eval_end:
+ \fi:
+ }
+\cs_new:Npn \@@_to_Letter:n #1
+ {
+ \exp_after:wN \exp_after:wN
+ \if_case:w \@@_eval:w #1 - \c_ten \@@_eval_end:
A
\or: B
\or: C
@@ -1927,15 +1989,17 @@
%\end{macro}
%\end{macro}
%
-% \begin{macro}{\int_to_binary:n, \int_to_hexadecimal:n, \int_to_octal:n}
+% \begin{macro}{\int_to_bin:n, \int_to_hex:n, \int_to_Hex:n, \int_to_oct:n}
% \UnitTested
% Wrappers around the generic function.
% \begin{macrocode}
-\cs_new:Npn \int_to_binary:n #1
+\cs_new:Npn \int_to_bin:n #1
{ \int_to_base:nn {#1} { 2 } }
-\cs_new:Npn \int_to_hexadecimal:n #1
+\cs_new:Npn \int_to_hex:n #1
{ \int_to_base:nn {#1} { 16 } }
-\cs_new:Npn \int_to_octal:n #1
+\cs_new:Npn \int_to_Hex:n #1
+ { \int_to_Base:nn {#1} { 16 } }
+\cs_new:Npn \int_to_oct:n #1
{ \int_to_base:nn {#1} { 8 } }
% \end{macrocode}
% \end{macro}
@@ -2141,15 +2205,15 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\int_from_binary:n, \int_from_hexadecimal:n, \int_from_octal:n}
+% \begin{macro}{\int_from_bin:n, \int_from_hex:n, \int_from_oct:n}
% \UnitTested
% Wrappers around the generic function.
% \begin{macrocode}
-\cs_new:Npn \int_from_binary:n #1
+\cs_new:Npn \int_from_bin:n #1
{ \int_from_base:nn {#1} \c_two }
-\cs_new:Npn \int_from_hexadecimal:n #1
+\cs_new:Npn \int_from_hex:n #1
{ \int_from_base:nn {#1} \c_sixteen }
-\cs_new:Npn \int_from_octal:n #1
+\cs_new:Npn \int_from_oct:n #1
{ \int_from_base:nn {#1} \c_eight }
% \end{macrocode}
% \end{macro}
@@ -2363,6 +2427,22 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\int_to_binary:n, \int_from_binary:n}
+% \begin{macro}{\int_to_hexadecimal:n, \int_from_hexadecimal:n}
+% \begin{macro}{\int_to_octal:n, \int_from_octal:n}
+% Deprecated 2014-02-11.
+% \begin{macrocode}
+\cs_new_eq:NN \int_to_binary:n \int_to_bin:n
+\cs_new_eq:NN \int_to_hexadecimal:n \int_to_Hex:n
+\cs_new_eq:NN \int_to_octal:n \int_to_oct:n
+\cs_new_eq:NN \int_from_binary:n \int_from_bin:n
+\cs_new_eq:NN \int_from_hexadecimal:n \int_from_hex:n
+\cs_new_eq:NN \int_from_octal:n \int_from_oct:n
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
% \begin{macrocode}
%</initex|package>
% \end{macrocode}