"GOTO Kentaro" <gotoken / notwork.org> schrieb im Newsbeitrag
news:20041016.034016.41636370.gotoken / notwork.org...
> In message Re: Rounding to X digits
>   on Thu, 14 Oct 2004 23:49:31 +0900, wrote "Robert Klemme":
> > 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.
>
> And there is an algorithmic difference: many implementation of
> sprintf(3) conform to ISO 31-0 but Float#round doesn't.
>
>     puts 0.5.round             #=> 1
>     puts sprintf("%.0f", 0.5)  #=> 0

Which version of Ruby are you using?

>> sprintf("%.0f", 0.5)
=> "1"
>> RUBY_VERSION
=> "1.8.1"

Regards

    robert