x <- c(0.9,0.81,32.52,0); nchar(sub('^0+','',sub('\\.','',x)));
This breaks the decimal point, then breaks all the leading zeros, and finally uses the string length as an indirect means of calculating the number of significant digits. It naturally returns zero for null input, but you can use the if expression to explicitly test for this case and, if you want, return it instead.
As mentioned in akrun, for printing with two digits after a decimal number:
sprintf('%.2f',x);
source share