It depends mostly on the expected input and also on the context where you want to use the command.
If your expected input is either a number or something that doesn't start with digits, then
\newcommand{\mycommand}[1]{%
\ifnum0<0#1\relax
#1 is a positive number%
\else
#1 is not a positive number%
\fi}
will do. For example, \mycommand{42}
will do the comparison 0<042
which is true; instead, with \mycommand{*}
TeX will see \ifnum0<0*\relax
and it will test 0<0
, which is false, so the *
will be ignored as part of the "true text". Also the test from \mycommand{0}
will evaluate to false.
On the other hand, with \mycommand{1x}
the test will evaluate to true and give wrong results.
Another expandable way can be
\def\mycommand#1{%
\if\relax\detokenize\expandafter{\romannumeral-0#1}\relax
#1 is a number%
\else
#1 is not a number%
\fi
}
but \mycommand{0}
would test true. Here \mycommand{1x}
would answer that 1x
is not a number.
However, the argument should not contain "dangerous" items: \mycommand{\textbf{x}}
would fail miserably.
A non-expandable test can be
\makeatletter
\def\mycommand#1{%
\afterassignment\get@args\count@=0#1\hfuzz#1\hfuzz}
\def\get@args#1\hfuzz#2\hfuzz{%
\if\relax\detokenize{#1}\relax
#2 is a number%
\else
#2 is not a number%
\fi
}
\makeatother
This works also with input such as \mycommand{\textbf{1}}
(the test will evaluate to false).
\ifnum
, (La)TeX does form numbers by expanding expandable tokens. Thus your request implies also checking whether the tokens forming the "given parameter" at the stage of expansion form an algorithm which terminates at all and which does not trigger errors. This is the halting problem.