From: James Edward Gray II Date: 2006-02-28T22:53:34+09:00 Subject: Re: Formatting to "Thousands" On Feb 28, 2006, at 5:08 AM, Barrie Jarman wrote: > A colleague of mine wishes to format a float to include commas at > thousand > values, for example > 12345.21 becomes > 12,345.21 > > Is there any inbuilt functionality to format this, or are we better of > writing something ourselves... It's not built-in, but it's also pretty easy to roll one: def commify( number ) number.to_s.reverse.gsub!(/(\d\d\d)(?=\d)(?!\d*\.)/, '\1,').reverse end Hope that helps. James Edward Gray II