ifthen package then
actually I mis read your condition so I suppose the full version is
I think all the answers given so far (including mine above) are not expandable which means that you can't to the test in places like a
\edef see the
\typeout below. Given your
\sqrt example that probably doesn't matter, but the following is a version using expandable tests that is almost certainly the quickest version posted so far, although rather expensive in terms of command name use.