How to check whether an argument is a floating point in LaTeX

Viewed 319

I need to check whether the argument passed is a floating point. I found this (very clever) code, but it only works on integers:

\newcommand{\test}[1]{{ 
    \if!\ifnum9<1#1!\else_\fi
       it is an integer
    \else
        it is something else
    \fi 
}}

This code works because it very cleverly reduces to an empty string if it is not a number. I tried to adapt it to floating numbers, but in this case i have to provide a unit of measurement, so this empty-string hack does not work anymore.

\newcommand{\test}[1]{{ 
    \if!\ifdim9pt<1#1pt!\else_\fi
       it is a float
    \else
        it is something else
    \fi 
}}

Any ideas how I can get around this issue of supplying a unit? Any other idea how to easily check for floating numbers? (the simpler the better) Thanks in advance.

1 Answers
Related