From: "Mark J. Reed" Date: 2003-12-10T01:07:02+09:00 Subject: Re: format money On Tue, Dec 09, 2003 at 05:19:41AM -0800, saggmannen wrote: > both your solutions work fine if the number of decimals is less than > or equal to three. What if I would like more precision than that in my > output? Eg. > > 2111000.5567 => "2,111,000.5567" The original poster specifically wanted rounding to the nearest ..01, as is normal when formatting amounts currency. When there might be three or more digits after the decimal point the solution is slightly more complex, especially since most people don't want commas to the right of the decimal point, but might want to see spaces there. This is where Numeric#format_s in the extensions library comes in handy. It's common when formatting individual numbers in running text (as opposed to columns of numbers in a table etc.) not to put the separators on either side of the decimal if there are only four digits: 12,345.678 90 but 1234.5678. An option to handle that in format_s would be nice . . . -Mark