Next: , Previous: \ifempty, Up: Expansion


7.6.8 \ifinteger and \isinteger

\ifinteger{arg} t \else f \fi expands the t text if arg is an integer, and the f text otherwise. This macro can detect positive and negative integers.

Since \ifinteger is not a primitive conditional, it cannot be used in places where TeX might skip tokens “at high speed”, e.g., within another conditional—TeX can't match up the \if's and \fi's. For such situations Eplain provides \isinteger, which can be used as follows:

     \if\isinteger{arg} t \else f \fi

Although \ifinteger and \isinteger work well with regular input, they are not bullet-proof. For example, the following code

     \ifinteger{12_ab}integer\else not integer\fi

will expand to ‘ab_integer’ (and thus would not even compile outside math mode).

These macros come from TeX Frequently Asked Question (http://www.tex.ac.uk/cgi-bin/texfaq2html).