I cannot figure out how to test if an argument is a floating point or integer using expl3.
Take this simple example where I convert \milk{number} into \dotfill, the number, and gallon or gallons with or without the s appropriately, or a special case for 0, empty. The last line, for Albert, causes an error with the classic cryptic error message:
! Use of \??? doesn't match its definition.
<argument> \???
! LaTeX Error: Unknown fp word none.
l.28 Albert has \milk{none}
By testing if #1 is in fact a floating point, I think I would be able to handle this error, but \tl_is_fp or even \tl_is_int don't seem to exist. How can I test if any arbitrary argument is a floating point or integer?
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\milk}{m}{%
\fp_compare:nTF {#1 = 0}{%if 0 replace with empty
\dotfill ~ empty%
}{\fp_compare:nTF {#1 <= 1}{% s or no s
\dotfill ~ #1~gallon%
}{\dotfill ~ #1~gallons%
}
}
}
\ExplSyntaxOff
\begin{document}
Ron has \milk{0}
Tom has \milk{1/2}
Timy has \milk{1}
John has \milk{2}
Albert has \milk{-}
\end{document}

int(a different type0 but test if the floating point is an integer (so floor(x)=x)intor if it is an expression which evaluates to an integer? anintis, basically, a texcount. so to test if something is anintis to test whether it is something created (at the tex level) by\newcount(which is what\int_new:Ndoes with some extra checks etc.). so2is not anint. don't you really want to know whether the argument is equal to an integer?expl3variable. but there is a difference between anint, adimand atl, for example. if you trylatexdef \l_tmpa_int, you can see it is\count25i.e. it is not a macro but a register. whereaslatexdef \l_tmpa_tlshows it is a macro. I don't know if this counts as a difference between data types in the sense of other programming languages, but these are different at the tex level.\def\tempa{0}creates a macro - not a count.abs(9*3-100), but you might also have user-defined functions. so distinguishing whether it can be evaluated as an fp without trying to evaluate it as an fp looks tricky to me?