You could use pgf for this. It has a \pgfmathsetbasenumberlength setting used for the base conversion macros. Setting it to 2 and do a dummy conversion the counter value to base 10 will give you 01, 02, ..., 10, etc. It also scales well, i.e. you can just use 3 and get 001, etc. However, for smaller things I would use egreg's solution instead.
\documentclass{article}
\usepackage{pgf}
\newcounter{mycounter}
\newcommand\test{{%
\pgfmathsetbasenumberlength{2}% try 3, 4, ...
\pgfmathbasetodec\testvalue{\the\value{mycounter}}{10}%
\testvalue
\stepcounter{mycounter}%
}}
\begin{document}
\test
\test
\test
\test
\test
\test
\test
\test
\test
\test
\test
\end{document}
Please also see the PGF manual section 66 Number Printing which should also be interesting for you.
\Opensolutionfile{ans}[prefixCOUNTER]which is part of theanswerspackage. And your approach works fine in that context. – maxschlepzig Oct 08 '11 at 14:46animatepackage as the command\@anim@padIt can be used as\makeatletter\@anim@pad{\mynumber}{\arabic{mycounter}}\makeatotherprovided\usepackage{animate}is included in the preamble. – 0 _ Jul 29 '14 at 08:14