%% %% This is file `l3int.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% l3int.dtx (with options: `package,trace') %% %% %% EXPERIMENTAL CODE %% %% Do not distribute this file without also distributing the %% source files specified above. %% %% Do not distribute a modified version of this file. %% %% %% File: l3int.dtx Copyright (C) 1990-2009 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 %% license or (at your option) any later version. The latest version %% of this license is in the file %% %% http://www.latex-project.org/lppl.txt %% %% This file is part of the ``expl3 bundle'' (The Work in LPPL) %% and all files in that bundle must be distributed together. %% %% The released version of this bundle is available from CTAN. %% %% ----------------------------------------------------------------------- %% %% The development version of the bundle can be found at %% %% http://www.latex-project.org/svnroot/experimental/trunk/ %% %% for those people who are interested. %% %%%%%%%%%%% %% NOTE: %% %%%%%%%%%%% %% %% Snapshots taken from the repository represent work in progress and may %% not work or may contain conflicting material! We therefore ask %% people _not_ to put them into distributions, archives, etc. without %% prior consultation with the LaTeX Project Team. %% %% ----------------------------------------------------------------------- \RequirePackage{l3names} \GetIdInfo$Id: l3int.dtx 1933 2010-05-25 00:26:38Z will $ {L3 Experimental Integer module} \ProvidesExplPackage {\filename}{\filedate}{\fileversion}{\filedescription} \package_check_loaded_expl: \cs_new_eq:NN \int_to_roman:w \tex_romannumeral:D \cs_new_eq:NN \int_to_number:w \tex_number:D \cs_new_eq:NN \int_advance:w \tex_advance:D \cs_new_protected_nopar:Npn \int_new:N #1 { \chk_if_free_cs:N #1 \newcount #1 } \cs_generate_variant:Nn \int_new:N {c} \cs_new_protected_nopar:Npn \int_set:Nn #1#2{#1 \intexpr_eval:w #2\intexpr_eval_end: } \cs_new_protected_nopar:Npn \int_gset:Nn { \pref_global:D \int_set:Nn } \cs_generate_variant:Nn\int_set:Nn {cn} \cs_generate_variant:Nn\int_gset:Nn {cn} \cs_new_protected_nopar:Npn \int_incr:N #1{\int_advance:w#1\c_one } \cs_new_protected_nopar:Npn \int_decr:N #1{\int_advance:w#1\c_minus_one } \cs_new_protected_nopar:Npn \int_gincr:N { \pref_global:D \int_incr:N} \cs_new_protected_nopar:Npn \int_gdecr:N { \pref_global:D \int_decr:N} \cs_set_protected_nopar:Npn \int_incr:N #1{\int_add:Nn#1\c_one} \cs_set_protected_nopar:Npn \int_decr:N #1{\int_add:Nn#1\c_minus_one} \cs_set_protected_nopar:Npn \int_gincr:N #1{\int_gadd:Nn#1\c_one} \cs_set_protected_nopar:Npn \int_gdecr:N #1{\int_gadd:Nn#1\c_minus_one} \cs_generate_variant:Nn \int_incr:N {c} \cs_generate_variant:Nn \int_decr:N {c} \cs_generate_variant:Nn \int_gincr:N {c} \cs_generate_variant:Nn \int_gdecr:N {c} \cs_new_protected_nopar:Npn \int_zero:N #1 {#1=\c_zero} \cs_generate_variant:Nn \int_zero:N {c} \cs_new_protected_nopar:Npn \int_gzero:N #1 {\pref_global:D #1=\c_zero} \cs_generate_variant:Nn \int_gzero:N {c} \cs_new_protected_nopar:Npn \int_add:Nn #1#2{ \int_advance:w #1 by \intexpr_eval:w #2\intexpr_eval_end: } \cs_new_nopar:Npn \int_sub:Nn #1#2{ \int_advance:w #1-\intexpr_eval:w #2\intexpr_eval_end: } \cs_new_protected_nopar:Npn \int_gadd:Nn { \pref_global:D \int_add:Nn } \cs_new_protected_nopar:Npn \int_gsub:Nn { \pref_global:D \int_sub:Nn } \cs_generate_variant:Nn \int_add:Nn {cn} \cs_generate_variant:Nn \int_gadd:Nn {cn} \cs_generate_variant:Nn \int_sub:Nn {cn} \cs_generate_variant:Nn \int_gsub:Nn {cn} \cs_new_eq:NN \int_use:N \tex_the:D \cs_new_nopar:Npn \int_use:c #1{\int_use:N \cs:w#1\cs_end:} \cs_new_eq:NN \int_show:N \kernel_register_show:N \cs_new_eq:NN \int_show:c \kernel_register_show:c \cs_new_nopar:Npn \int_to_arabic:n #1{ \intexpr_eval:n{#1}} \cs_new_protected_nopar:Npn \int_roman_lcuc_mapping:Nnn #1#2#3{ \cs_set_nopar:cpn {int_to_lc_roman_#1:}{#2} \cs_set_nopar:cpn {int_to_uc_roman_#1:}{#3} } \int_roman_lcuc_mapping:Nnn i i I \int_roman_lcuc_mapping:Nnn v v V \int_roman_lcuc_mapping:Nnn x x X \int_roman_lcuc_mapping:Nnn l l L \int_roman_lcuc_mapping:Nnn c c C \int_roman_lcuc_mapping:Nnn d d D \int_roman_lcuc_mapping:Nnn m m M \int_roman_lcuc_mapping:Nnn Q \use_none:nn \use_none:nn \cs_new_nopar:Npn \int_to_roman:n #1 { \exp_after:wN \int_to_roman_lcuc:NN \exp_after:wN l \int_to_roman:w \intexpr_eval:n {#1} Q } \cs_new_nopar:Npn \int_to_Roman:n #1 { \exp_after:wN \int_to_roman_lcuc:NN \exp_after:wN u \int_to_roman:w \intexpr_eval:n {#1} Q } \cs_new_nopar:Npn \int_to_roman_lcuc:NN #1#2{ \use:c {int_to_#1c_roman_#2:} \int_to_roman_lcuc:NN #1 } \cs_set_nopar:Npn \int_convert_number_with_rule:nnN #1#2#3{ \intexpr_compare:nNnTF {#1}>{#2} { \exp_args:Nf \int_convert_number_with_rule:nnN { \intexpr_div_truncate:nn {#1-1}{#2} }{#2} #3 \exp_args:Nf #3 { \intexpr_eval:n{1+\intexpr_mod:nn {#1-1}{#2}} } } { \exp_args:Nf #3{ \intexpr_eval:n{#1} } } } \cs_new_nopar:Npn \int_alph_default_conversion_rule:n #1{ \if_case:w #1 \or: 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 \fi: } \cs_new_nopar:Npn \int_Alph_default_conversion_rule:n #1{ \if_case:w #1 \or: 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 \fi: } \cs_new_nopar:Npn \int_to_alph:n #1{ \int_convert_number_with_rule:nnN {#1}{26} \int_alph_default_conversion_rule:n } \cs_new_nopar:Npn \int_to_Alph:n #1{ \int_convert_number_with_rule:nnN {#1}{26} \int_Alph_default_conversion_rule:n } \cs_new_nopar:Npn \int_to_symbol:n #1{ \mode_if_math:TF { \int_convert_number_with_rule:nnN {#1}{9} \int_symbol_math_conversion_rule:n } { \int_convert_number_with_rule:nnN {#1}{9} \int_symbol_text_conversion_rule:n } } \cs_new_nopar:Npn \int_symbol_math_conversion_rule:n #1 { \if_case:w #1 \or: * \or: \dagger \or: \ddagger \or: \mathsection \or: \mathparagraph \or: \| \or: ** \or: \dagger\dagger \or: \ddagger\ddagger \fi: } \cs_new_nopar:Npn \int_symbol_text_conversion_rule:n #1 { \if_case:w #1 \or: \textasteriskcentered \or: \textdagger \or: \textdaggerdbl \or: \textsection \or: \textparagraph \or: \textbardbl \or: \textasteriskcentered\textasteriskcentered \or: \textdagger\textdagger \or: \textdaggerdbl\textdaggerdbl \fi: } \int_new:N \l_tmpa_int \int_new:N \l_tmpb_int \int_new:N \l_tmpc_int \int_new:N \g_tmpa_int \int_new:N \g_tmpb_int \cs_set_nopar:Npn \int_pre_eval_one_arg:Nn #1#2{ \exp_args:Nf#1{\intexpr_eval:n{#2}}} \cs_set_nopar:Npn \int_pre_eval_two_args:Nnn #1#2#3{ \exp_args:Nff#1{\intexpr_eval:n{#2}}{\intexpr_eval:n{#3}} } \cs_new_protected_nopar:Npn \int_const:Nn #1#2 { \intexpr_compare:nTF { #2 > \c_minus_one } { \intexpr_compare:nTF { #2 > \c_max_register_int } { \int_new:N #1 \int_gset:Nn #1 {#2} } { \chk_if_free_cs:N #1 \tex_global:D \tex_mathchardef:D #1 = \intexpr_eval:n {#2} } } { \int_new:N #1 \int_gset:Nn #1 {#2} } } %% \tex_countdef:D \c_minus_one = 10 \scan_stop: %% \c_minus_one = -1 \scan_stop: %% in l3basics \int_const:Nn \c_one {1} \int_const:Nn \c_two {2} \int_const:Nn \c_three {3} \int_const:Nn \c_four {4} \int_const:Nn \c_five {5} \int_const:Nn \c_six {6} \int_const:Nn \c_seven {7} \int_const:Nn \c_eight {8} \int_const:Nn \c_nine {9} \int_const:Nn \c_ten {10} \int_const:Nn \c_eleven {11} \int_const:Nn \c_twelve {12} \int_const:Nn \c_thirteen {13} \int_const:Nn \c_fourteen {14} \int_const:Nn \c_fifteen {15} %% \tex_chardef:D \c_sixteen = 16\scan_stop: %% in l3basics \int_const:Nn \c_thirty_two {32} \int_const:Nn \c_hundred_one {101} \int_const:Nn \c_twohundred_fifty_five{255} \int_const:Nn \c_twohundred_fifty_six {256} \int_const:Nn \c_thousand {1000} \int_const:Nn \c_ten_thousand {10000} \int_const:Nn \c_ten_thousand_one {10001} \int_const:Nn \c_ten_thousand_two {10002} \int_const:Nn \c_ten_thousand_three {10003} \int_const:Nn \c_ten_thousand_four {10004} \int_const:Nn \c_twenty_thousand {20000} \int_const:Nn \c_max_int {2147483647} \cs_new_nopar:Npn \int_get_sign_and_digits:n #1{ \int_get_sign_and_digits_aux:nNNN {#1} \c_true_bool \c_true_bool \c_true_bool } \cs_new_nopar:Npn \int_get_sign:n #1{ \int_get_sign_and_digits_aux:nNNN {#1} \c_true_bool \c_true_bool \c_false_bool } \cs_new_nopar:Npn \int_get_digits:n #1{ \int_get_sign_and_digits_aux:nNNN {#1} \c_true_bool \c_false_bool \c_true_bool } \cs_new_nopar:Npn \int_get_sign_and_digits_aux:nNNN #1#2#3#4{ \tl_if_head_eq_charcode:fNTF {#1} - { \bool_if:NTF #2 { \int_get_sign_and_digits_aux:oNNN {\use_none:n #1} \c_false_bool #3#4 } { \int_get_sign_and_digits_aux:oNNN {\use_none:n #1} \c_true_bool #3#4 } } { \tl_if_head_eq_charcode:fNTF {#1} + { \int_get_sign_and_digits_aux:oNNN {\use_none:n #1} #2#3#4} { \bool_if:NT #3 { \bool_if:NF #2 - } \bool_if:NT #4 {#1} } } } \cs_generate_variant:Nn \int_get_sign_and_digits_aux:nNNN {oNNN} \cs_set_nopar:Npn \int_convert_from_base_ten:nn#1#2{ \intexpr_compare:nNnTF {#1}<\c_zero { - \int_convert_from_base_ten_aux:nfn {} { \intexpr_eval:n {-#1} } } { \int_convert_from_base_ten_aux:nfn {} { \intexpr_eval:n {#1} } } {#2} } \cs_new_nopar:Npn \int_convert_from_base_ten_aux:nnn#1#2#3{ \intexpr_compare:nNnTF {#2}<{#3} { \int_convert_number_to_letter:n{#2} #1 } { \int_convert_from_base_ten_aux:ffn { \int_convert_number_to_letter:n {\intexpr_mod:nn {#2}{#3}} #1 } { \intexpr_div_truncate:nn{#2}{#3}} {#3} } } \cs_generate_variant:Nn \int_convert_from_base_ten_aux:nnn {nfn} \cs_generate_variant:Nn \int_convert_from_base_ten_aux:nnn {ffn} \cs_set_nopar:Npn \int_convert_number_to_letter:n #1{ \if_case:w \intexpr_eval:w #1-10\intexpr_eval_end: \exp_after:wN A \or: \exp_after:wN B \or: \exp_after:wN C \or: \exp_after:wN D \or: \exp_after:wN E \or: \exp_after:wN F \or: \exp_after:wN G \or: \exp_after:wN H \or: \exp_after:wN I \or: \exp_after:wN J \or: \exp_after:wN K \or: \exp_after:wN L \or: \exp_after:wN M \or: \exp_after:wN N \or: \exp_after:wN O \or: \exp_after:wN P \or: \exp_after:wN Q \or: \exp_after:wN R \or: \exp_after:wN S \or: \exp_after:wN T \or: \exp_after:wN U \or: \exp_after:wN V \or: \exp_after:wN W \or: \exp_after:wN X \or: \exp_after:wN Y \or: \exp_after:wN Z \else: \use_i_after_fi:nw{ #1 }\fi: } \cs_set_nopar:Npn \int_convert_to_base_ten:nn #1#2 { \intexpr_eval:n{ \int_get_sign:n{#1} \exp_args:Nf\int_convert_to_base_ten_aux:nn {\int_get_digits:n{#1}}{#2} } } \cs_new_nopar:Npn \int_convert_to_base_ten_aux:nn #1#2{ \int_convert_to_base_ten_auxi:nnN {0}{#2} #1 \q_nil } \cs_new_nopar:Npn \int_convert_to_base_ten_auxi:nnN#1#2#3{ \quark_if_nil:NTF #3 {#1} {\exp_args:Nf\int_convert_to_base_ten_auxi:nnN {\intexpr_eval:n{ #1*#2+\int_convert_letter_to_number:N #3} } {#2} } } \cs_set_nopar:Npn \int_convert_letter_to_number:N #1{ \intexpr_compare:nNnTF{`#1}<{58}{#1} { \intexpr_eval:n{ `#1 - \intexpr_compare:nNnTF{`#1}<{91}{ 55 }{ 87 } } } } \int_new:N \g_tl_inline_level_int %% %% %% End of file `l3int.sty'.