From: GOTO Kentaro Date: 2004-10-16T03:34:20+09:00 Subject: Re: Rounding to X digits 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 Gotoken