Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
thousandth separator
bmgz
1/15/2006 8:56:00 PM
I am in need of a *simple* thousandth separtor function or something ie.
1000000.00 => 1,000,000.00
is their any simple solution to this?
2 Answers
Gene Tani
1/15/2006 10:23:00 PM
0
bmgz wrote:
> I am in need of a *simple* thousandth separtor function or something ie.
>
> 1000000.00 => 1,000,000.00
>
> is their any simple solution to this?
you can input numbers with "_" as sort of a thousands separator, so
400_000 == 400000
for output, something like this:
http://rubyforge.org/snippet/detail.php?type=snippe...
If you need anything locale-specific (e.g. switch between "," and "."
depenging on where you are, I'm not aware of anything like python
locale.format or locale.str. Googling shows lots of hits on *local*
vars or whatever. Let us know if you find anything
Gene Tani
1/18/2006 4:37:00 PM
0
Gene Tani wrote:
> bmgz wrote:
> > I am in need of a *simple* thousandth separtor function or something ie.
> >
> > 1000000.00 => 1,000,000.00
> >
> > is their any simple solution to this?
>
> you can input numbers with "_" as sort of a thousands separator, so
>
> 400_000 == 400000
>
> for output, something like this:
>
http://rubyforge.org/snippet/detail.php?type=snippe...
>
> If you need anything locale-specific (e.g. switch between "," and "."
> depenging on where you are, I'm not aware of anything like python
> locale.format or locale.str. Googling shows lots of hits on *local*
> vars or whatever. Let us know if you find anything
locale-specific formatting: Numeric#format_s in extensions gives
fine-grained control over currency, thousands separators, negatives,
decimal point, etc
http://extensions.rubyforge.org/rdoc/...
(i knew it was here somehwere, just took a couple days)
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
thousandth separator
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password