File: ifisinteger.tex

package info (click to toggle)
texlive-extra 2024.20250309-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 5,368,476 kB
  • sloc: perl: 401,582; xml: 41,345; python: 38,753; cs: 25,850; sh: 18,555; makefile: 17,174; ansic: 13,023; java: 12,811; javascript: 9,898; lisp: 1,876; csh: 1,347; ruby: 618; awk: 183; tcl: 142; pascal: 138; cpp: 124; sed: 92; haskell: 5
file content (44 lines) | stat: -rw-r--r-- 1,728 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
\catcode`\@=11 %  use the private prefix ``II@''
\newif\ifII@itis      % main result of the macro
%% helper macros
\def\II@rmsign #1{\ifx#1+\else\ifx#1-\else
 \II@endrm#1\fi\fi\II@rmsign}
\def\II@endrm #1\fi\fi#2{\fi\fi#1}
\def\II@zeros #1{\ifx#1''\else\ifx#1""\else
 \II@cont#1\fi\fi\II@zeros}
\def\II@cont #1\fi\fi#2{\fi\fi\II@hdlzero#1}
\def\II@hdlzero #1{\ifx#10 \else
 \II@xchgfi #1\fi\II@hdlzero}
\def\II@xchgfi #1\fi#2{\fi\ifx#1`\else0\fi#1}
%% constants with the sentinel `W'
\def\II@cfd{02147483647W}%  canonical forms with
\def\II@cfh{"07FFFFFFFW}% W of TeX's max integer
\def\II@cfo{'017777777777W}%    in dec, hex, oct
\def\II@W{W}\def\II@hexW{"W}% all unsigned input
\def\II@octW{'W}% with W for which TeX inserts 0
%% assignments
\let\Boolend=\iffalse \font\II@font=cmr10
\let\IIcurrentmode=\errorstopmode    % CONFIGURE
%% main macro
\def\ifisint #1\Boolend{\II@itisfalse % see S1.2
 \edef\II@digs{\II@rmsign#1W}% S1.1 with 2 \edef
 \edef\II@digs{\expandafter\II@rmsign\II@digs}%
 \ifx\II@digs\II@W\else\ifx\II@digs\II@octW
 \else\ifx\II@digs\II@hexW\else  % S1.2 finished
  \edef\II@cf{\expandafter\II@zeros\II@digs}% S2
  \wlog{=== start ignore}\batchmode\begingroup
   \setbox0=\hbox{\count255=\II@cf
    \xdef\II@val{\the\count255}}%
   \setbox0=\hbox{\II@font\count255=#1W}%   S3.1
   \xdef\II@wd{\the\wd0}%
  \endgroup\IIcurrentmode\wlog{=== stop ignore}%
  \ifdim\II@wd=10.2778pt % \wd of hbox `W'; S3.2
   \II@itistrue \ifnum\II@val=2147483647 %  S4.1
    \ifx\II@cf\II@cfd
    \else\ifx\II@cf\II@cfh
    \else\ifx\II@cf\II@cfo                % S4.2
    \else \II@itisfalse                   % S4.3
   \fi\fi\fi\fi
  \else \II@itisfalse                     % S3.3
 \fi\fi\fi\fi \ifII@itis}
\catcode`\@=12