I am searching for a reliable way to determine whether a String can be fed into \pgfmathprintnumber. I used to use the \IfDecimal from the xstring package which works fine for things like 3.14 and similar inputs. However \pgfmathprintnumber can deal with scientific notation that will be sorted out by \IfDecimal because it thinks that it is not a number.
Here's an MWE:
\documentclass{article}
\usepackage{pgf}
\usepackage{xstring}
\begin{document}
\def\testNum{3E+64}
\IfDecimal{\testNum}{
\pgfmathprintnumber[sci]{\testNum} is a number
}{
\pgfmathprintnumber[sci]{\testNum} is not a number
}
\end{document}
As you'll see the number is properly recognized by \pgfmathprintnumber but not by \IfDecimal.
(I also tried the \DTLisnumerical command from the datatool package but it doesn't work either).
Does someone know a macro that will also detect scientific notations as numbers (preferably a validation by PGF itself - something that will try to parse the string with the mathematical engine but simply exits if the string can't be parsed as a number instead of killing LaTeX with an error)?
