John Kopanas wrote:

> ahhh... yes... now how do we take it up a notch and divide thousand
> from hundreds... for example:
> 
> $10,343 or better yet $1,234,234.32

This approach ignores a certain locale issue, but:

--------------------------------------
#!/usr/bin/ruby -w

class String
   def currency_format()
      while self.sub!(/(\d+)(\d\d\d)/,'\1,\2'); end
      self
   end
end

0.upto(20) do |n|
   x = 10 ** n
   xs = x.to_s + ".33"
   puts xs.currency_format().rjust(30)
end
--------------------------------------

                          1.33
                         10.33
                        100.33
                      1,000.33
                     10,000.33
                    100,000.33
                  1,000,000.33
                 10,000,000.33
                100,000,000.33
              1,000,000,000.33
             10,000,000,000.33
            100,000,000,000.33
          1,000,000,000,000.33
         10,000,000,000,000.33
        100,000,000,000,000.33
      1,000,000,000,000,000.33
     10,000,000,000,000,000.33
    100,000,000,000,000,000.33
  1,000,000,000,000,000,000.33
 10,000,000,000,000,000,000.33
100,000,000,000,000,000,000.33

-- 
Paul Lutus
http://www.arachnoid.com