As discussed in http://www.ruby-forum.com/topic/1060694#new with apparently no objection, this is a request for an easy way to get comma separated string values from numeric types.
Background:
Currently in ruby you can enter large numbers with digit grouping:
a = 1_000_000_000
however there is no convenient way to convert from a number back to digit grouping
Suggestion:
1_000_000_000.grouped
=> "1,000,000,000"
class Numeric
def separate(sep=",")
self.to_s.reverse.scan(/(?:\d*.)?\d{1,3}-?/).join(sep).reverse
end
end
Another option would be to support this extended printf syntax:
As nobu said numbering system depends on locales. So far ruby has been strictly avoiding locale-dependent features. It is too careless to introduce such feature.
As nobu said numbering system depends on locales. So far ruby has been
strictly avoiding locale-dependent features. It is too careless to
introduce such feature.
I'd be down with some local independent implementation, like java's
new DecimalFormat( "#,###,###,##0.00" );
basically.
Cheers!
roger