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