"Eric Anderson" <eric / afaik.us> schrieb im Newsbeitrag
news:GZvbd.111$FV6.46 / fe61.usenetserver.com...
> James Edward Gray II wrote:
> > You're looking for sprintf():
>
> *Slaps hand on head*

*Hands over some cooling ice*
:-)

> I didn't even think about sprintf. I guess I was so fixed on looking for
> a way to round numbers in the various Numeric objects that it didn't
> occur to me to look in the string functionality.
>
> sprintf() still seems a bit to C-ish for me. I kind of like my round
> extension that allows for an optional arg. The question is my
> implementation more efficient or using sprintf more efficient? Benchmark
> to the rescue:

The difference in efficiency is one issue.  But there is a conceptual
difference: it depends whether you want to align printed output or round a
numeric value in a calculation.  For the first task sprintf is probably
better because the amount of places printed is guaranteed (by the format
string), while it's not if you just round the number and print it.

Kind regards

    robert