Significant Digits revisited

Has anybody been able to create a reliable way to format a number to show a specified number of significant digits?

The one Dimitri posted a while back has some limitations.

Thanks.
Robin